From dd8bd1aa363a55a9fe064e12507a1333988ee83a Mon Sep 17 00:00:00 2001 From: Dave Dash Date: Tue, 4 Jan 2011 10:28:05 -0800 Subject: [PATCH] bug 618622, remove personas from default search. --- apps/search/client.py | 3 +++ apps/search/tests/test_views.py | 13 +++++++------ apps/search/views.py | 2 ++ settings.py | 3 +++ 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/apps/search/client.py b/apps/search/client.py index 510193a625..5f0ba4c759 100644 --- a/apps/search/client.py +++ b/apps/search/client.py @@ -104,6 +104,9 @@ def extract_filters(term, kwargs): addon_type = types.get(addon_type.lower()) filters['type'] = addon_type + elif settings.SEARCH_EXCLUDE_PERSONAS and not kwargs.get('show_personas'): + # by default, we exclude Personas + excludes['type'] = amo.ADDON_PERSONA # Guid filtering.. (term, guids) = extract_from_query(term, 'guid', '[\s{}@_\.,\-0-9a-zA-Z]+', diff --git a/apps/search/tests/test_views.py b/apps/search/tests/test_views.py index 9953567ac7..5bb0dca233 100644 --- a/apps/search/tests/test_views.py +++ b/apps/search/tests/test_views.py @@ -50,17 +50,18 @@ class PersonaSearchTest(SphinxTestCase): class FrontendSearchTest(SphinxTestCase): fixtures = ('base/addon_3615', 'base/appversions', - 'base/addon_6704_grapple') - - def setUp(self): - # Warms up the prefixer. - self.client.get('/') - super(FrontendSearchTest, self).setUp() + 'base/addon_6704_grapple', 'addons/persona') def get_response(self, **kwargs): return self.client.get(reverse('search.search') + '?' + urllib.urlencode(kwargs)) + def test_default_no_personas(self): + """Reverting the personas experiment... for now. bug 618622""" + r = self.get_response(q='My Persona') + doc = pq(r.content) + eq_(len(doc('.item')), 0) + def test_xss(self): """Inputs should be escaped so people don't XSS.""" r = self.get_response(q='>My Balls') diff --git a/apps/search/views.py b/apps/search/views.py index fa3a58ffc8..166abd503e 100644 --- a/apps/search/views.py +++ b/apps/search/views.py @@ -283,6 +283,8 @@ def search(request, tag_name=None): addon_type = form.cleaned_data.get('atype', 0) tag = tag_name if tag_name is not None else form.cleaned_data.get('tag') + if tag_name: + search_opts['show_personas'] = True page = form.cleaned_data['page'] sort = form.cleaned_data.get('sort') diff --git a/settings.py b/settings.py index cab706c58b..c4c90d4556 100644 --- a/settings.py +++ b/settings.py @@ -692,3 +692,6 @@ QUNIT_TEST_DIRECTORY = os.path.join(MEDIA_ROOT, 'js', 'zamboni', 'tests') # binary. It must be a version compatible with amo-validator SPIDERMONKEY = None VALIDATE_ADDONS = True + +# Feature flags +SEARCH_EXCLUDE_PERSONAS = True