def extension_detail(request, addon): """Extensions details page.""" # If current version is incompatible with this app, redirect. comp_apps = addon.compatible_apps if comp_apps and request.APP not in comp_apps: prefixer = urlresolvers.get_url_prefix() prefixer.app = comp_apps.keys()[0].short return redirect('addons.detail', addon.slug, permanent=True) # Popular collections this addon is part of. collections = Collection.objects.listed().filter( addons=addon, application=request.APP.id) ctx = { 'addon': addon, 'src': request.GET.get('src', 'dp-btn-primary'), 'version_src': request.GET.get('src', 'dp-btn-version'), 'tags': addon.tags.not_blacklisted(), 'grouped_ratings': GroupedRating.get(addon.id), 'review_form': ReviewForm(), 'reviews': Review.without_replies.all().filter( addon=addon, is_latest=True), 'get_replies': Review.get_replies, 'collections': collections.order_by('-subscribers')[:3], 'abuse_form': AbuseForm(request=request), } # details.html just returns the top half of the page for speed. The bottom # does a lot more queries we don't want on the initial page load. if request.is_ajax(): # Other add-ons/apps from the same author(s). ctx['author_addons'] = addon.authors_other_addons(app=request.APP)[:6] return render(request, 'addons/impala/details-more.html', ctx) else: return render(request, 'addons/impala/details.html', ctx)
def extension_detail(request, addon): """Extensions details page.""" # If current version is incompatible with this app, redirect. comp_apps = addon.compatible_apps if comp_apps and request.APP not in comp_apps: prefixer = urlresolvers.get_url_prefix() prefixer.app = comp_apps.keys()[0].short return redirect('addons.detail', addon.slug, permanent=True) # Popular collections this addon is part of. collections = Collection.objects.listed().filter( addons=addon, application=request.APP.id) ctx = { 'addon': addon, 'src': request.GET.get('src', 'dp-btn-primary'), 'version_src': request.GET.get('src', 'dp-btn-version'), 'tags': addon.tags.not_denied(), 'grouped_ratings': GroupedRating.get(addon.id), 'review_form': ReviewForm(), 'reviews': Review.without_replies.all().filter( addon=addon, is_latest=True).exclude(body=None), 'get_replies': Review.get_replies, 'collections': collections.order_by('-subscribers')[:3], 'abuse_form': AbuseForm(request=request), } # details.html just returns the top half of the page for speed. The bottom # does a lot more queries we don't want on the initial page load. if request.is_ajax(): # Other add-ons/apps from the same author(s). ctx['author_addons'] = addon.authors_other_addons(app=request.APP)[:6] return render(request, 'addons/impala/details-more.html', ctx) else: return render(request, 'addons/impala/details.html', ctx)
def test_get_none(self): assert GroupedRating.get(3, update_none=False) is None
def test_update_none(self): eq_(GroupedRating.get(1865, update_none=False), None) eq_(GroupedRating.get(1865, update_none=True), self.grouped_ratings)
def test_cron(self): eq_(GroupedRating.get(1865, update_none=False), None) tasks.addon_grouped_rating(1865) eq_(GroupedRating.get(1865, update_none=False), self.grouped_ratings)
def test_cron(self): assert GroupedRating.get(self.addon.pk, update_none=False) is None tasks.addon_grouped_rating(self.addon.pk) assert GroupedRating.get( self.addon.pk, update_none=False) == (self.expected_grouped_rating)
def test_cron(self): assert GroupedRating.get(self.addon.pk, update_none=False) is None tasks.addon_grouped_rating(self.addon.pk) assert GroupedRating.get(self.addon.pk, update_none=False) == ( self.expected_grouped_rating)
def test_update_none(self): assert GroupedRating.get(1865, update_none=False) is None assert GroupedRating.get(1865, update_none=True) == (self.grouped_ratings)
def test_set(self): assert GroupedRating.get(1865, update_none=False) is None GroupedRating.set(1865) assert GroupedRating.get(1865, update_none=False) == ( self.grouped_ratings)
def test_set(self): eq_(GroupedRating.get(1865, update_none=False), None) GroupedRating.set(1865) eq_(GroupedRating.get(1865, update_none=False), self.grouped_ratings)
def test_get_none(self): eq_(GroupedRating.get(3, update_none=False), None)
def test_update_none(self): assert GroupedRating.get(self.addon.pk, update_none=False) is None assert GroupedRating.get( self.addon.pk, update_none=True) == (self.expected_grouped_rating)
def test_set(self): assert GroupedRating.get(1865, update_none=False) is None GroupedRating.set(1865) assert GroupedRating.get(1865, update_none=False) == (self.grouped_ratings)
def test_cron(self): assert GroupedRating.get(1865, update_none=False) is None tasks.addon_grouped_rating(1865) assert GroupedRating.get(1865, update_none=False) == (self.grouped_ratings)
def test_cron(self): assert GroupedRating.get(1865, update_none=False) is None tasks.addon_grouped_rating(1865) assert GroupedRating.get(1865, update_none=False) == ( self.grouped_ratings)
def test_get_unknown_addon_id(self): assert GroupedRating.get(3, update_none=False) is None assert GroupedRating.get(3) == [(1, 0), (2, 0), (3, 0), (4, 0), (5, 0)]
def test_update_none(self): assert GroupedRating.get(1865, update_none=False) is None assert GroupedRating.get(1865, update_none=True) == ( self.grouped_ratings)
def test_update_none(self): assert GroupedRating.get(self.addon.pk, update_none=False) is None assert GroupedRating.get(self.addon.pk, update_none=True) == ( self.expected_grouped_rating)