Exemplo n.º 1
0
def abuse_recaptcha(request, addon):
    form = AbuseForm(request.POST or None, request=request)
    if request.method == "POST" and form.is_valid():
        send_abuse_report(request, addon, form.cleaned_data["text"])
        messages.success(request, _("Abuse reported."))
        return redirect(addon.get_url_path())
    else:
        return jingo.render(request, "detail/abuse_recaptcha.html", {"product": addon, "abuse_form": form})
Exemplo n.º 2
0
def report_abuse(request, user):
    form = AbuseForm(request.POST or None, request=request)
    if request.method == "POST" and form.is_valid():
        send_abuse_report(request, user, form.cleaned_data["text"])
        messages.success(request, _("User reported."))
    else:
        return jingo.render(request, "users/report_abuse_full.html", {"profile": user, "abuse_form": form})
    return redirect(user.get_url_path())
Exemplo n.º 3
0
def report_abuse(request, addon):
    form = AbuseForm(request.POST or None, request=request)
    if request.method == "POST" and form.is_valid():
        send_abuse_report(request, addon, form.cleaned_data["text"])
        messages.success(request, _("Abuse reported."))
        return http.HttpResponseRedirect(addon.get_url_path())
    else:
        return render(request, "addons/report_abuse_full.html", {"addon": addon, "abuse_form": form})
Exemplo n.º 4
0
def report_abuse(request, addon):
    form = AbuseForm(request.POST or None, request=request)
    if request.method == "POST" and form.is_valid():
        send_abuse_report(request, addon, form.cleaned_data['text'])
        messages.success(request, _('Abuse reported.'))
        return redirect('addons.detail', addon.slug)
    else:
        return jingo.render(request, 'addons/report_abuse_full.html',
                            {'addon': addon, 'abuse_form': form, })
Exemplo n.º 5
0
def abuse(request, profile):
    form = AbuseForm(request.POST or None, request=request)
    if request.method == 'POST' and form.is_valid():
        send_abuse_report(request, profile, form.cleaned_data['text'])
        messages.success(request, _('Abuse reported.'))
        return redirect(reverse('users.profile', args=[profile.username]))
    else:
        return jingo.render(request, 'account/abuse.html',
                            {'abuse_form': form, 'profile': profile})
Exemplo n.º 6
0
def report_abuse(request, addon):
    form = AbuseForm(request.POST or None, request=request)
    if request.method == "POST" and form.is_valid():
        send_abuse_report(request, addon, form.cleaned_data['text'])
        messages.success(request, _('Abuse reported.'))
        return http.HttpResponseRedirect(addon.get_url_path())
    else:
        return jingo.render(request, 'addons/report_abuse_full.html',
                            {'addon': addon, 'abuse_form': form, })
Exemplo n.º 7
0
def report_abuse(request, user):
    form = AbuseForm(request.POST or None, request=request)
    if request.method == 'POST' and form.is_valid():
        send_abuse_report(request, user, form.cleaned_data['text'])
        messages.success(request, _('User reported.'))
    else:
        return render(request, 'users/report_abuse_full.html',
                      {'profile': user, 'abuse_form': form})
    return redirect(user.get_url_path())
Exemplo n.º 8
0
def report_abuse(request, addon):
    form = AbuseForm(request.POST or None, request=request)
    if request.method == "POST" and form.is_valid():
        send_abuse_report(request, addon, form.cleaned_data['text'])
        messages.success(request, _('Abuse reported.'))
        return http.HttpResponseRedirect(addon.get_url_path())
    else:
        return render(request, 'addons/report_abuse_full.html',
                      {'addon': addon, 'abuse_form': form})
Exemplo n.º 9
0
def report_abuse(request, user):
    form = AbuseForm(request.POST or None, request=request)
    if request.method == 'POST' and form.is_valid():
        send_abuse_report(request, user, form.cleaned_data['text'])
        messages.success(request, _('User reported.'))
    else:
        return jingo.render(request, 'users/report_abuse_full.html',
                            {'profile': user, 'abuse_form': form, })
    return redirect(user.get_url_path())
Exemplo n.º 10
0
def abuse_recaptcha(request, addon):
    form = AbuseForm(request.POST or None, request=request)
    if request.method == 'POST' and form.is_valid():
        send_abuse_report(request, addon, form.cleaned_data['text'])
        messages.success(request, _('Abuse reported.'))
        return redirect(addon.get_url_path())
    else:
        return jingo.render(request, 'detail/abuse_recaptcha.html',
                            {'product': addon, 'abuse_form': form})
Exemplo n.º 11
0
def report_abuse(request, user_id):
    user = get_object_or_404(UserProfile, pk=user_id)
    form = AbuseForm(request.POST or None, request=request)
    if request.method == "POST" and form.is_valid():
        send_abuse_report(request, user, form.cleaned_data["text"])
        messages.success(request, _("User reported."))
    else:
        return jingo.render(request, "users/report_abuse_full.html", {"profile": user, "abuse_form": form})
    return redirect(reverse("users.profile", args=[user.pk]))
Exemplo n.º 12
0
def report_abuse(request, user_id):
    user = get_object_or_404(UserProfile, pk=user_id)
    form = AbuseForm(request.POST or None, request=request)
    if request.method == "POST" and form.is_valid():
        send_abuse_report(request, user, form.cleaned_data['text'])
        messages.success(request, _('User reported.'))
    else:
        return jingo.render(request, 'users/report_abuse_full.html',
                            {'profile': user, 'abuse_form': form, })
    return redirect(reverse('users.profile', args=[user.pk]))
Exemplo n.º 13
0
def report_abuse(request, user_id):
    user = get_object_or_404(UserProfile, pk=user_id)
    form = AbuseForm(request.POST or None, request=request)
    if request.method == 'POST' and form.is_valid():
        send_abuse_report(request, user, form.cleaned_data['text'])
        messages.success(request, _('User reported.'))
    else:
        return jingo.render(request, 'users/report_abuse_full.html',
                            {'profile': user, 'abuse_form': form, })
    return redirect(reverse('users.profile', args=[user.pk]))
Exemplo n.º 14
0
def abuse(request, profile):
    form = AbuseForm(request.POST or None, request=request)
    if request.method == 'POST' and form.is_valid():
        send_abuse_report(request, profile, form.cleaned_data['text'])
        messages.success(request, _('Abuse reported.'))
        return redirect(reverse('users.profile', args=[profile.username]))
    else:
        return jingo.render(request, 'account/abuse.html', {
            'abuse_form': form,
            'profile': profile
        })
Exemplo n.º 15
0
def abuse(request, addon):
    form = AbuseForm(request.POST or None, request=request)
    if request.method == 'POST' and form.is_valid():
        send_abuse_report(request, addon, form.cleaned_data['text'])
        messages.success(request, _('Abuse reported.'))
        return redirect(addon.get_url_path())
    else:
        return jingo.render(request, 'detail/abuse.html', {
            'product': addon,
            'abuse_form': form
        })
Exemplo n.º 16
0
def abuse(request, user_id):
    user = get_object_or_404(UserProfile, pk=user_id)
    form = AbuseForm(request.POST or None, request=request)
    if request.method == 'POST' and form.is_valid():
        send_abuse_report(request, user, form.cleaned_data['text'])
        messages.success(request, _('Abuse reported.'))
        # We don't have a profile page to redirect back to. Once the abuse
        # is reported, that would be the place I'd recommend redirecting
        # back to.
        return redirect('/')
    else:
        return jingo.render(request, 'account/abuse.html',
                            {'user': user, 'abuse_form': form})
Exemplo n.º 17
0
def report_abuse(request, addon):
    if not settings.REPORT_ABUSE:
        raise http.Http404()

    form = AbuseForm(request.POST or None, request=request)
    if request.method == "POST" and form.is_valid():
        url = reverse('addons.detail', args=[addon.slug])
        send_abuse_report(request, addon, url, form.cleaned_data['text'])
        messages.success(request, _('Abuse reported.'))
    else:
        return jingo.render(request, 'addons/report_abuse_full.html',
                            {'addon': addon, 'abuse_form': form, })
    return redirect('addons.detail', addon.slug)
Exemplo n.º 18
0
def report_abuse(request, addon):
    if not settings.REPORT_ABUSE:
        raise http.Http404()

    form = AbuseForm(request.POST or None, request=request)
    if request.method == "POST" and form.is_valid():
        url = reverse('addons.detail', args=[addon.slug])
        send_abuse_report(request, addon, url, form.cleaned_data['text'])
        messages.success(request, _('Abuse reported.'))
        return redirect('addons.detail', addon.slug)
    else:
        return jingo.render(request, 'addons/report_abuse_full.html', {
            'addon': addon,
            'abuse_form': form,
        })
Exemplo n.º 19
0
def profile(request, user):
    # Temporary until we decide we want user profile pages.
    if settings.MARKETPLACE:
        raise http.Http404

    webapp = False

    # Get user's own and favorite collections, if they allowed that.
    own_coll = fav_coll = []
    if not webapp:
        if user.display_collections:
            own_coll = (Collection.objects.listed().filter(
                author=user).order_by('-created'))[:10]
        if user.display_collections_fav:
            fav_coll = (Collection.objects.listed().filter(
                following__user=user).order_by('-following__created'))[:10]

    edit_any_user = acl.action_allowed(request, 'Users', 'Edit')
    own_profile = (request.user.is_authenticated()
                   and request.amo_user.id == user.id)

    personas = []
    if user.is_developer:
        if webapp:
            items = user.apps_listed
        else:
            items = user.addons_listed.exclude(type=amo.ADDON_PERSONA)
            personas = user.addons_listed.filter(type=amo.ADDON_PERSONA)
        addons = amo.utils.paginate(request,
                                    items.order_by('-weekly_downloads'))
    else:
        addons = []

    def get_addons(reviews):
        if not reviews:
            return
        qs = Addon.objects.filter(id__in=set(r.addon_id for r in reviews))
        addons = dict((addon.id, addon) for addon in qs)
        for review in reviews:
            review.addon = addons.get(review.addon_id)

    # (Don't show marketplace reviews for AMO (since that would break))
    reviews = list(
        user.reviews.exclude(
            addon__type=amo.ADDON_WEBAPP).transform(get_addons))

    data = {
        'profile': user,
        'own_coll': own_coll,
        'reviews': reviews,
        'fav_coll': fav_coll,
        'edit_any_user': edit_any_user,
        'addons': addons,
        'own_profile': own_profile,
        'personas': personas
    }
    if not own_profile:
        data['abuse_form'] = AbuseForm(request=request)

    return jingo.render(request, 'users/profile.html', data)
Exemplo n.º 20
0
def profile(request, user):
    # Temporary until we decide we want user profile pages.
    if settings.MARKETPLACE:
        raise http.Http404

    webapp = False

    # Get user's own and favorite collections, if they allowed that.
    own_coll = fav_coll = []
    if not webapp:
        if user.display_collections:
            own_coll = (Collection.objects.listed().filter(
                author=user).order_by('-created'))[:10]
        if user.display_collections_fav:
            fav_coll = (Collection.objects.listed().filter(
                following__user=user).order_by('-following__created'))[:10]

    edit_any_user = acl.action_allowed(request, 'Users', 'Edit')
    own_profile = (request.user.is_authenticated()
                   and request.amo_user.id == user.id)

    addons = []
    personas = []
    limited_personas = False
    if user.is_developer:
        addons = user.addons.reviewed().exclude(type=amo.ADDON_WEBAPP).filter(
            addonuser__user=user, addonuser__listed=True)

        personas = addons.filter(
            type=amo.ADDON_PERSONA).order_by('-persona__popularity')
        if personas.count() > THEMES_LIMIT:
            limited_personas = True
            personas = personas[:THEMES_LIMIT]

        addons = addons.exclude(
            type=amo.ADDON_PERSONA).order_by('-weekly_downloads')
        addons = amo.utils.paginate(request, addons, 5)

    # Don't show marketplace reviews for AMO (since that would break).
    reviews = list(user.reviews.exclude(addon__type=amo.ADDON_WEBAPP))
    reviews = amo.utils.paginate(request, reviews)

    data = {
        'profile': user,
        'own_coll': own_coll,
        'reviews': reviews,
        'fav_coll': fav_coll,
        'edit_any_user': edit_any_user,
        'addons': addons,
        'own_profile': own_profile,
        'personas': personas,
        'limited_personas': limited_personas,
        'THEMES_LIMIT': THEMES_LIMIT
    }
    if not own_profile:
        data['abuse_form'] = AbuseForm(request=request)

    return render(request, 'users/profile.html', data)
Exemplo n.º 21
0
def detail(request, addon):
    """Product details page."""
    ctx = {
        'product': addon,
        'reviews': Review.objects.latest().filter(addon=addon),
    }
    if addon.is_public():
        ctx['abuse_form'] = AbuseForm(request=request)
    return jingo.render(request, 'detail/app.html', ctx)
Exemplo n.º 22
0
Arquivo: views.py Projeto: vdt/zamboni
def profile(request, user_id):
    webapp = settings.APP_PREVIEW
    user = get_object_or_404(UserProfile, id=user_id)

    # Get user's own and favorite collections, if they allowed that.
    own_coll = fav_coll = []
    if not webapp:
        if user.display_collections:
            own_coll = (Collection.objects.listed().filter(
                author=user).order_by('-created'))[:10]
        if user.display_collections_fav:
            fav_coll = (Collection.objects.listed().filter(
                following__user=user).order_by('-following__created'))[:10]

    edit_any_user = acl.action_allowed(request, 'Users', 'Edit')
    own_profile = (request.user.is_authenticated()
                   and request.amo_user.id == user.id)

    personas = []
    if user.is_developer:
        if webapp:
            items = user.apps_listed
        else:
            items = user.addons_listed.exclude(type=amo.ADDON_PERSONA)
            personas = user.addons_listed.filter(type=amo.ADDON_PERSONA)
        addons = amo.utils.paginate(request,
                                    items.order_by('-weekly_downloads'))
    else:
        addons = []

    def get_addons(reviews):
        if not reviews:
            return
        qs = Addon.objects.filter(id__in=set(r.addon_id for r in reviews))
        addons = dict((addon.id, addon) for addon in qs)
        for review in reviews:
            review.addon = addons.get(review.addon_id)

    reviews = user.reviews.transform(get_addons)

    data = {
        'profile': user,
        'own_coll': own_coll,
        'reviews': reviews,
        'fav_coll': fav_coll,
        'edit_any_user': edit_any_user,
        'addons': addons,
        'own_profile': own_profile,
        'webapp': webapp,
        'personas': personas
    }
    if not own_profile:
        data['abuse_form'] = AbuseForm(request=request)

    return jingo.render(request, 'users/profile.html', data)
Exemplo n.º 23
0
def persona_detail(request, addon, template=None):
    """Details page for Personas."""
    if not addon.is_public():
        raise http.Http404

    persona = addon.persona

    # this persona's categories
    categories = addon.categories.all()
    category_personas = None
    if categories.exists():
        qs = Addon.objects.public().filter(categories=categories[0])
        category_personas = _category_personas(qs, limit=6)

    data = {
        'addon': addon,
        'persona': persona,
        'categories': categories,
        'author_personas': persona.authors_other_addons()[:3],
        'category_personas': category_personas,
    }

    author = None
    if persona.is_new():
        try:
            author = addon.authors.all()[0]
        except IndexError:
            pass
        else:
            author = author.get_url_path(src='addon-detail')
    else:
        author = settings.PERSONAS_USER_ROOT % persona.author
    data['author_gallery'] = author

    if not request.MOBILE:
        # tags
        dev_tags, user_tags = addon.tags_partitioned_by_developer
        data.update({
            'dev_tags':
            dev_tags,
            'user_tags':
            user_tags,
            'review_form':
            ReviewForm(),
            'reviews':
            Review.objects.valid().filter(addon=addon, is_latest=True),
            'get_replies':
            Review.get_replies,
            'search_cat':
            'themes',
            'abuse_form':
            AbuseForm(request=request),
        })

    return jingo.render(request, template, data)
Exemplo n.º 24
0
def profile(request, user):
    # Get user's own and favorite collections, if they allowed that.
    own_coll = fav_coll = []
    if user.display_collections:
        own_coll = (Collection.objects.listed().filter(
            author=user).order_by('-created'))[:10]
    if user.display_collections_fav:
        fav_coll = (Collection.objects.listed().filter(
            following__user=user).order_by('-following__created'))[:10]

    edit_any_user = acl.action_allowed(request, 'Users', 'Edit')
    own_profile = (request.user.is_authenticated()
                   and request.amo_user.id == user.id)

    addons = []
    personas = []
    limited_personas = False
    if user.is_developer:
        addons = user.addons.reviewed().filter(addonuser__user=user,
                                               addonuser__listed=True)

        # TODO: temporary, remove this when 1020465 has landed.
        addons = addons.exclude(type=amo.ADDON_WEBAPP)

        personas = addons.filter(
            type=amo.ADDON_PERSONA).order_by('-persona__popularity')
        if personas.count() > THEMES_LIMIT:
            limited_personas = True
            personas = personas[:THEMES_LIMIT]

        addons = addons.exclude(
            type=amo.ADDON_PERSONA).order_by('-weekly_downloads')
        addons = amo.utils.paginate(request, addons, 5)

    reviews = amo.utils.paginate(
        request,
        # TODO: temporary, remove the exclude when 1020465 has landed.
        user.reviews.all().exclude(addon__type=amo.ADDON_WEBAPP))

    data = {
        'profile': user,
        'own_coll': own_coll,
        'reviews': reviews,
        'fav_coll': fav_coll,
        'edit_any_user': edit_any_user,
        'addons': addons,
        'own_profile': own_profile,
        'personas': personas,
        'limited_personas': limited_personas,
        'THEMES_LIMIT': THEMES_LIMIT
    }
    if not own_profile:
        data['abuse_form'] = AbuseForm(request=request)

    return render(request, 'users/profile.html', data)
Exemplo n.º 25
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)

    # get satisfaction only supports en-US.
    lang = translation.to_locale(translation.get_language())
    addon.has_satisfaction = (lang == 'en_US' and
                              addon.get_satisfaction_company)

    # Addon recommendations.
    recommended = Addon.objects.listed(request.APP).filter(
        recommended_for__addon=addon)[:6]

    # Popular collections this addon is part of.
    collections = Collection.objects.listed().filter(
        addons=addon, application__id=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),
        'recommendations': recommended,
        'review_form': ReviewForm(),
        'reviews': Review.objects.latest().filter(addon=addon),
        '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).
        if addon.is_webapp():
            others = Webapp.objects.listed().filter(type=amo.ADDON_WEBAPP)
        else:
            others = (Addon.objects.listed(request.APP)
                      .exclude(type=amo.ADDON_WEBAPP))
        others = (others.exclude(id=addon.id).distinct()
                        .filter(addonuser__listed=True,
                                authors__in=addon.listed_authors))
        ctx['author_addons'] = others[:6]
        return jingo.render(request, 'addons/impala/details-more.html', ctx)
    else:
        if addon.is_webapp():
            ctx['search_placeholder'] = 'apps'
        return jingo.render(request, 'addons/impala/details.html', ctx)
Exemplo n.º 26
0
def impala_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 http.HttpResponsePermanentRedirect(
            reverse('addons.detail', args=[addon.slug]))

    # source tracking
    src = request.GET.get('src', 'addon-detail')

    # get satisfaction only supports en-US
    lang = translation.to_locale(translation.get_language())
    addon.has_satisfaction = (lang == 'en_US'
                              and addon.get_satisfaction_company)

    # other add-ons from the same author(s)
    author_addons = order_by_translation(addon.authors_other_addons,
                                         'name')[:6]

    # tags
    tags = addon.tags.not_blacklisted()

    # addon recommendations
    recommended = MiniAddon.objects.valid().filter(
        recommended_for__addon=addon)[:5]

    # popular collections this addon is part of
    collections = Collection.objects.listed().filter(
        addons=addon, application__id=request.APP.id)

    data = {
        'addon': addon,
        'author_addons': author_addons,
        'src': src,
        'tags': tags,
        'grouped_ratings': GroupedRating.get(addon.id),
        'recommendations': recommended,
        'review_form': ReviewForm(),
        'reviews': Review.objects.latest().filter(addon=addon),
        'get_replies': Review.get_replies,
        'collections': collections.order_by('-subscribers')[:3],
    }
    if settings.REPORT_ABUSE:
        data['abuse_form'] = AbuseForm(request=request)

    return jingo.render(request, 'addons/impala/details.html', data)
Exemplo n.º 27
0
def profile(request, user_id):
    """user profile display page"""
    user = get_object_or_404(UserProfile, id=user_id)

    # get user's own and favorite collections, if they allowed that
    if user.display_collections:
        own_coll = (Collection.objects.listed().filter(
            author=user).order_by('-created'))[:10]
    else:
        own_coll = []
    if user.display_collections_fav:
        fav_coll = (Collection.objects.listed().filter(
            following__user=user).order_by('-following__created'))[:10]
    else:
        fav_coll = []

    edit_any_user = acl.action_allowed(request, 'Admin', 'EditAnyUser')
    own_profile = request.user.is_authenticated() and (request.amo_user.id
                                                       == user.id)

    if user.is_developer:
        addons = amo.utils.paginate(
            request, user.addons_listed.order_by('-weekly_downloads'))
    else:
        addons = []

    def get_addons(reviews):
        if not reviews:
            return
        qs = Addon.objects.filter(id__in=set(r.addon_id for r in reviews))
        addons = dict((addon.id, addon) for addon in qs)
        for review in reviews:
            review.addon = addons.get(review.addon_id)

    reviews = user.reviews.transform(get_addons)

    data = {
        'profile': user,
        'own_coll': own_coll,
        'reviews': reviews,
        'fav_coll': fav_coll,
        'edit_any_user': edit_any_user,
        'addons': addons,
        'own_profile': own_profile
    }

    if settings.REPORT_ABUSE:
        data['abuse_form'] = AbuseForm(request=request)

    return jingo.render(request, 'users/profile.html', data)
Exemplo n.º 28
0
def detail(request, addon):
    """Product details page."""
    ratings = Rating.objects.latest().filter(addon=addon).order_by('-created')
    positive_ratings = list(ratings.filter(score=1)[:5])
    negative_ratings = list(ratings.filter(score=-1)[:5])
    sorted_ratings = sorted(positive_ratings + negative_ratings,
                            key=lambda x: x.created,
                            reverse=True)
    ctx = {
        'product': addon,
        'ratings': ratings,
        'ratings': sorted_ratings,
        'review_history': [[2, 12], [50, 2], [3, 0], [4, 1]]
    }
    if addon.is_public():
        ctx['abuse_form'] = AbuseForm(request=request)
    return jingo.render(request, 'detail/app.html', ctx)
Exemplo n.º 29
0
def persona_detail(request, addon, template=None):
    """Details page for Personas."""
    if not addon.is_public():
        raise http.Http404

    persona = addon.persona

    # this persona's categories
    categories = addon.categories.filter(application=request.APP.id)
    if categories:
        qs = Addon.objects.public().filter(categories=categories[0])
        category_personas = _category_personas(qs, limit=6)
    else:
        category_personas = None

    # other personas from the same author(s)
    author_personas = Addon.objects.public().filter(
        persona__author=persona.author,
        type=amo.ADDON_PERSONA).exclude(
            pk=addon.pk).select_related('persona')[:3]

    data = {
        'addon': addon,
        'persona': persona,
        'categories': categories,
        'author_personas': author_personas,
        'category_personas': category_personas,
    }
    if not persona.is_new():
        # Remora uses persona.author despite there being a display_username.
        data['author_gallery'] = settings.PERSONAS_USER_ROOT % persona.author
    if not request.MOBILE:
        # tags
        dev_tags, user_tags = addon.tags_partitioned_by_developer
        data.update({
            'dev_tags': dev_tags,
            'user_tags': user_tags,
            'review_form': ReviewForm(),
            'reviews': Review.objects.latest().filter(addon=addon),
            'get_replies': Review.get_replies,
            'search_cat': 'personas',
            'abuse_form': AbuseForm(request=request),
        })

    return jingo.render(request, template, data)
Exemplo n.º 30
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)

    # Addon recommendations.
    recommended = Addon.objects.listed(request.APP).filter(
        recommended_for__addon=addon)[:6]

    # Popular collections this addon is part of.
    collections = Collection.objects.listed().filter(
        addons=addon, application__id=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),
        'recommendations': recommended,
        'review_form': ReviewForm(),
        'reviews': Review.objects.valid().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 jingo.render(request, 'addons/impala/details-more.html', ctx)
    else:
        if addon.is_webapp():
            ctx['search_placeholder'] = 'apps'
        return jingo.render(request, 'addons/impala/details.html', ctx)
Exemplo n.º 31
0
def detail(request, addon):
    """Product details page."""
    reviews = Review.objects.latest().filter(addon=addon)
    ctx = {
        'product':
        addon,
        'reviews':
        reviews[:2],
        'flags':
        get_flags(request, reviews),
        'has_review':
        request.user.is_authenticated()
        and reviews.filter(user=request.user.id).exists(),
        'grouped_ratings':
        GroupedRating.get(addon.id),
        'details_page':
        True
    }
    if addon.is_public():
        ctx['abuse_form'] = AbuseForm(request=request)
    return jingo.render(request, 'detail/app.html', ctx)
Exemplo n.º 32
0
def persona_detail(request, addon):
    """Details page for Personas."""
    persona = addon.persona

    # this persona's categories
    categories = addon.categories.filter(application=request.APP.id)
    if categories:
        qs = Addon.objects.valid().filter(categories=categories[0])
        category_personas = _category_personas(qs, limit=6)
    else:
        category_personas = None

    # tags
    dev_tags, user_tags = addon.tags_partitioned_by_developer

    # other personas from the same author(s)
    author_personas = Addon.objects.valid().filter(
        persona__author=persona.author, type=amo.ADDON_PERSONA).exclude(
            pk=addon.pk).select_related('persona')[:3]

    data = {
        'addon': addon,
        'persona': persona,
        'categories': categories,
        'author_personas': author_personas,
        'category_personas': category_personas,
        'dev_tags': dev_tags,
        'user_tags': user_tags,
        'review_form': ReviewForm(),
        'reviews': Review.objects.latest().filter(addon=addon),
        'get_replies': Review.get_replies,
        # Remora users persona.author despite there being a display_username
        'author_gallery': settings.PERSONAS_USER_ROOT % persona.author,
        'search_cat': 'personas',
    }
    if settings.REPORT_ABUSE:
        data['abuse_form'] = AbuseForm(request=request)

    return jingo.render(request, 'addons/persona_detail.html', data)