do not filter site search on appversion for Firefox 10+ for D2C (bug 751735)

This commit is contained in:
Chris Van 2012-05-04 13:47:09 -07:00
Родитель 6b35998c94
Коммит c7b8a982cd
2 изменённых файлов: 22 добавлений и 2 удалений

Просмотреть файл

@ -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']

Просмотреть файл

@ -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: