Skip to content

Commit

Permalink
Merge branch 'no-personas'
Browse files Browse the repository at this point in the history
  • Loading branch information
davedash committed Jan 11, 2011
2 parents 4c53414 + dd8bd1a commit 682faa1
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 26 deletions.
3 changes: 0 additions & 3 deletions apps/addons/views.py
Expand Up @@ -61,9 +61,6 @@ def decorated(request, *args, **kwargs):
@addon_view
def addon_detail(request, addon):
"""Add-ons details page dispatcher."""
if settings.SANDBOX_PANIC and addon.status in amo.UNREVIEWED_STATUSES:
raise http.Http404

# addon needs to have a version and be valid for this app.
if addon.type in request.APP.types:
if addon.type == amo.ADDON_PERSONA:
Expand Down
18 changes: 5 additions & 13 deletions apps/search/client.py
Expand Up @@ -49,7 +49,6 @@ def extract_filters(term, kwargs):
# the model, this index is based on the db column.
filters = {'inactive': 0}
excludes = {}
ranges = {}

# Status filtering
filters['addon_status'] = SEARCHABLE_STATUSES
Expand Down Expand Up @@ -83,13 +82,6 @@ def extract_filters(term, kwargs):
('type' not in kwargs or kwargs['type'] != amo.ADDON_PERSONA)):
excludes['num_files'] = 0

# STATUS_DISABLED and 0 (which likely means null) are filtered
excludes['addon_status'] = (amo.STATUS_NULL, amo.STATUS_DISABLED,)

if settings.SANDBOX_PANIC:
excludes['addon_status'] = (excludes['addon_status'] +
amo.UNREVIEWED_STATUSES)

(term, platform) = extract_from_query(term, 'platform', '\w+', kwargs)

# platform filtering
Expand All @@ -112,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]+',
Expand Down Expand Up @@ -145,7 +140,7 @@ def extract_filters(term, kwargs):
else:
filters['tag'] = -1

return (term, filters, excludes, ranges)
return (term, filters, excludes)


def get_locale_ord():
Expand Down Expand Up @@ -382,17 +377,14 @@ def query(self, term, limit=10, offset=0, **kwargs):
sc.SetFieldWeights({'name': 100})

# Extract and apply various filters.
(term, includes, excludes, ranges) = extract_filters(term, kwargs)
(term, includes, excludes) = extract_filters(term, kwargs)

for filter, value in includes.iteritems():
self.add_filter(filter, value)

for filter, value in excludes.iteritems():
self.add_filter(filter, value, exclude=True)

for filter, value in ranges.iteritems():
self.sphinx.SetFilterRange(filter, value[0], value[1])

# Sanitize the term before we start adding queries.
term = sanitize_query(term)

Expand Down
13 changes: 7 additions & 6 deletions apps/search/tests/test_views.py
Expand Up @@ -50,17 +50,18 @@ def test_default_personas_query(self):

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='><strong>My Balls</strong>')
Expand Down
2 changes: 2 additions & 0 deletions apps/search/views.py
Expand Up @@ -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')

Expand Down
8 changes: 4 additions & 4 deletions settings.py
Expand Up @@ -631,10 +631,6 @@ def JINJA_CONFIG():
CSP_FONT_SRC = ("'self'", "fonts.mozilla.com", "www.mozilla.com", )
CSP_FRAME_ANCESTORS = ("'none'",) # We also send x-frame-options:DENY

# If you don't want experimental add-ons to show up in any search results or
# have detail pages, flip this switch
SANDBOX_PANIC = False

# Should robots.txt deny everything or disallow a calculated list of URLs we
# don't want to be crawled? Default is false, disallow everything.
ENGAGE_ROBOTS = False
Expand All @@ -645,6 +641,7 @@ def JINJA_CONFIG():
# Do you want the Fx4 beta promo to show up? bug 592690
BETA_PROMO = True


# Turn on read-only mode in settings_local.py by putting this line
# at the VERY BOTTOM: read_only_mode(globals())
def read_only_mode(env):
Expand Down Expand Up @@ -695,3 +692,6 @@ def read_only_mode(env):
# binary. It must be a version compatible with amo-validator
SPIDERMONKEY = None
VALIDATE_ADDONS = True

# Feature flags
SEARCH_EXCLUDE_PERSONAS = True

0 comments on commit 682faa1

Please sign in to comment.