Example #1
0
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)
Example #2
0
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)
Example #3
0
 def test_get_none(self):
     assert GroupedRating.get(3, update_none=False) is None
Example #4
0
 def test_update_none(self):
     eq_(GroupedRating.get(1865, update_none=False), None)
     eq_(GroupedRating.get(1865, update_none=True), self.grouped_ratings)
Example #5
0
 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)
Example #6
0
 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)
Example #7
0
 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)
Example #8
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)
Example #9
0
 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)
Example #10
0
 def test_get_none(self):
     assert GroupedRating.get(3, update_none=False) is None
Example #11
0
 def test_update_none(self):
     eq_(GroupedRating.get(1865, update_none=False), None)
     eq_(GroupedRating.get(1865, update_none=True), self.grouped_ratings)
Example #12
0
 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)
Example #13
0
 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)
Example #14
0
 def test_get_none(self):
     eq_(GroupedRating.get(3, update_none=False), None)
Example #15
0
 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)
Example #16
0
 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)
Example #17
0
 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)
Example #18
0
 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)
Example #19
0
 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)]
Example #20
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)
Example #21
0
 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)
Example #22
0
 def test_get_none(self):
     eq_(GroupedRating.get(3, update_none=False), None)
Example #23
0
 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)
Example #24
0
 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)]