diff --git a/apps/browse/tests.py b/apps/browse/tests.py index 93bf553826..75f4d37a9d 100644 --- a/apps/browse/tests.py +++ b/apps/browse/tests.py @@ -21,7 +21,7 @@ from amo.urlresolvers import reverse from amo.helpers import absolutify, numberfmt, urlparams from addons.tests.test_views import TestMobile from addons.models import (Addon, AddonCategory, Category, AppSupport, Feature, - Persona) + FrozenAddon, Persona) from addons.utils import FeaturedManager from applications.models import Application from bandwagon.models import Collection, CollectionAddon, FeaturedCollection @@ -1323,6 +1323,24 @@ class TestPersonas(amo.tests.TestCase): r = self.client.get(category_url) self.assertTemplateUsed(r, landing) + def test_personas_category_landing_frozen(self): + # Check to make sure add-on is there. + category_url = reverse('browse.personas') + r = self.client.get(category_url) + + personas = pq(r.content).find('.persona-preview') + eq_(personas.length, 2) + eq_(personas.eq(1).find('a').text(), "My Persona") + + # Freeze the add-on + FrozenAddon.objects.create(addon_id=15663) + + # Make sure it's not there anymore + res = self.client.get(category_url) + + personas = pq(res.content).find('.persona-preview') + eq_(personas.length, 1) + class TestMobileFeatured(TestMobile): diff --git a/apps/browse/views.py b/apps/browse/views.py index 5f60a4a80d..e0199b6d81 100644 --- a/apps/browse/views.py +++ b/apps/browse/views.py @@ -15,7 +15,7 @@ import amo import amo.models from amo.models import manual_order from amo.urlresolvers import reverse -from addons.models import Addon, Category, AddonCategory +from addons.models import Addon, AddonCategory, Category, FrozenAddon from addons.utils import FeaturedManager, CreaturedManager from addons.views import BaseFilter, ESBaseFilter from translations.query import order_by_translation @@ -310,8 +310,11 @@ def personas_listing(request, category=None): type=TYPE) categories = order_by_translation(q, 'name') + frozen = FrozenAddon.objects.values_list('addon', flat=True) + base = (Addon.objects.public().filter(type=TYPE) - .extra(select={'_app': request.APP.id})) + .exclude(id__in=frozen) + .extra(select={'_app': request.APP.id})) if category is not None: category = get_object_or_404(q, slug=category)