Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 3
0
 def test_get_none(self):
     assert GroupedRating.get(3, update_none=False) is None
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 10
0
 def test_get_none(self):
     assert GroupedRating.get(3, update_none=False) is None
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 14
0
 def test_get_none(self):
     eq_(GroupedRating.get(3, update_none=False), None)
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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)]
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 22
0
 def test_get_none(self):
     eq_(GroupedRating.get(3, update_none=False), None)
Ejemplo n.º 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)
Ejemplo n.º 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)]