Skip to content
This repository was archived by the owner on Mar 15, 2018. It is now read-only.

Commit f42883b

Browse files
committed
Hide apps from API search (bug 728070)
1 parent f8e8ffa commit f42883b

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

apps/api/tests/test_views.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,11 @@ def test_defaults(self):
552552
response = make_call('list')
553553
self.assertContains(response, '<addon id', 3)
554554

555+
def test_ignore_apps(self):
556+
Addon.objects.update(type=amo.ADDON_WEBAPP)
557+
response = make_call('list')
558+
self.assertNotContains(response, '<addon id')
559+
555560
def test_type_filter(self):
556561
"""
557562
This tests that list filtering works.
@@ -834,6 +839,12 @@ def test_search_for_specifics(self):
834839
response = self.client.get(url)
835840
self.assertContains(response, text, msg_prefix=url)
836841

842+
def test_ignore_apps(self):
843+
Addon.objects.update(type=amo.ADDON_WEBAPP)
844+
self.reindex(Addon)
845+
rp = self.client.get('/en-US/firefox/api/1.2/search/delicious')
846+
self.assertNotContains(rp, 'Delicious')
847+
837848
def test_search_limits(self):
838849
"""
839850
Test that we limit our results correctly.

apps/api/views.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,9 @@ def process_request(self, query, addon_type='ALL', limit=10,
339339

340340
qs = Addon.search().query(or_=name_query(query))
341341
filters.update(qs_filters)
342+
if 'type' not in filters:
343+
# Filter by ALL types, which is really all types except for apps.
344+
filters['type__in'] = list(amo.ADDON_SEARCH_TYPES)
342345
qs = qs.filter(**filters)
343346

344347
return self.render('api/search.xml', {
@@ -400,7 +403,7 @@ def process_request(self, list_type='recommended', addon_type='ALL',
400403
"""
401404
limit = min(MAX_LIMIT, int(limit))
402405
APP, platform = self.request.APP, platform.lower()
403-
qs = Addon.objects.listed(APP)
406+
qs = Addon.objects.listed(APP).exclude(type=amo.ADDON_WEBAPP)
404407
shuffle = True
405408

406409
if list_type in ('by_adu', 'featured'):

0 commit comments

Comments
 (0)