def filter_featured(self): # Featured search add-ons in all locales: APP, LANG = self.request.APP, self.request.LANG ids = FeaturedManager.featured_ids(APP, LANG, amo.ADDON_SEARCH) try: search_cat = Category.objects.get(slug="search-tools", application=APP.id) others = CreaturedManager.creatured_ids(search_cat, LANG) ids.extend(o for o in others if o not in ids) except Category.DoesNotExist: pass return manual_order(Addon.objects.valid(), ids, "addons.id")
def filter_featured(self): # Featured search add-ons in all locales: APP, LANG = self.request.APP, self.request.LANG ids = FeaturedManager.featured_ids(APP, LANG, amo.ADDON_SEARCH) try: search_cat = Category.objects.get(slug='search-tools', application=APP.id) others = CreaturedManager.creatured_ids(search_cat, LANG) ids.extend(o for o in others if o not in ids) except Category.DoesNotExist: pass return manual_order(Addon.objects.valid(), ids, 'addons.id')
def impala_home(request): # Add-ons. base = Addon.objects.listed(request.APP).filter(type=amo.ADDON_EXTENSION) featured_ext = FeaturedManager.featured_ids(request.APP, request.LANG, type=amo.ADDON_EXTENSION) featured_personas = FeaturedManager.featured_ids(request.APP, request.LANG, type=amo.ADDON_PERSONA) # This is lame for performance. Kill it with ES. frozen = FrozenAddon.objects.values_list('addon', flat=True) # Collections. collections = Collection.objects.filter(listed=True, application=request.APP.id, type=amo.COLLECTION_FEATURED) featured = base.filter(id__in=featured_ext[:18]) popular = base.exclude(id__in=frozen).order_by('-average_daily_users')[:10] hotness = base.exclude(id__in=frozen).order_by('-hotness')[:18] personas = (Addon.objects.listed(request.APP) .filter(type=amo.ADDON_PERSONA, id__in=featured_personas[:18])) return jingo.render(request, 'addons/impala/home.html', {'popular': popular, 'featured': featured, 'hotness': hotness, 'personas': personas, 'src': 'homepage', 'collections': collections})
def get_featured_personas(request): categories, filter, base, category = personas_listing(request) ids = FeaturedManager.featured_ids(request.APP, request.LANG, type=amo.ADDON_PERSONA) return manual_order(base, ids)[:6]
def get_featured_personas(request): categories, filter, base, category = personas_listing(request) ids = FeaturedManager.featured_ids(request.APP, request.LANG, type=amo.ADDON_PERSONA) return manual_order(base, ids)[:6]
def get_featured_personas(request, category=None, num_personas=6): categories, filter, base, category = personas_listing(request, category) ids = FeaturedManager.featured_ids(request.APP, request.LANG, type=amo.ADDON_PERSONA) return manual_order(base, ids, 'addons.id')[:num_personas]
def get_featured_personas(request, category=None, num_personas=6): categories, filter, base, category = personas_listing(request, category) ids = FeaturedManager.featured_ids(request.APP, request.LANG, type=amo.ADDON_PERSONA) return manual_order(base, ids, 'addons.id')[:num_personas]