From c7b8a982cdbb63e63a844d9ba7b65b2f75e63a30 Mon Sep 17 00:00:00 2001 From: Chris Van Date: Fri, 4 May 2012 13:47:09 -0700 Subject: [PATCH] do not filter site search on appversion for Firefox 10+ for D2C (bug 751735) --- apps/search/tests/test_views.py | 16 ++++++++++++++++ apps/search/views.py | 8 ++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/apps/search/tests/test_views.py b/apps/search/tests/test_views.py index d75f652611..c5f28e6a24 100644 --- a/apps/search/tests/test_views.py +++ b/apps/search/tests/test_views.py @@ -639,6 +639,22 @@ class TestESSearch(SearchBase): eq_(r.status_code, 200) eq_(self.get_results(r), themes) + def test_results_respect_appver_filtering(self): + r = self.client.get(self.url, dict(appver='9.00')) + eq_(self.get_results(r), []) + + def test_results_skip_appver_filtering_for_d2c(self): + r = self.client.get(self.url, dict(appver='10.0a1')) + eq_(self.get_results(r), + sorted(self.addons.values_list('id', flat=True))) + + def test_results_respect_appver_filtering_for_non_extensions(self): + self.addons.update(type=amo.ADDON_THEME) + r = self.client.get(self.url, dict(appver='10.0a1', + type=amo.ADDON_THEME)) + eq_(self.get_results(r), + sorted(self.addons.values_list('id', flat=True))) + class TestPersonaSearch(SearchBase): fixtures = ['base/apps'] diff --git a/apps/search/views.py b/apps/search/views.py index 2562443f42..213c01c17a 100644 --- a/apps/search/views.py +++ b/apps/search/views.py @@ -528,8 +528,12 @@ def _filter_search(request, qs, query, filters, sorting, low = version_int(query['appver']) # Get a max version greater than X.0a. high = version_int(query['appver'] + 'a') - qs = qs.filter(**{'appversion.%s.max__gte' % APP.id: high, - 'appversion.%s.min__lte' % APP.id: low}) + # If we're not using D2C then fall back to appversion checking. + extensions_shown = (not query.get('atype') or + query['atype'] == amo.ADDON_EXTENSION) + if not extensions_shown or low < version_int('10.0'): + qs = qs.filter(**{'appversion.%s.max__gte' % APP.id: high, + 'appversion.%s.min__lte' % APP.id: low}) if 'atype' in show and query['atype'] in amo.ADDON_TYPES: qs = qs.filter(type=query['atype']) else: