コード例 #1
0
def report_abuse(request, model, app_label, pk):
    """Report abusive or irrelavent content."""
    if request.method == 'POST':
        # we only use the form for the csrf middleware. skip validation.
        form = AbuseForm(request.POST)
        content_type_cls = get_object_or_404(
            ContentType, model=model, app_label=app_label).model_class()
        instance = get_object_or_404(content_type_cls, pk=pk)
        try:
            url = request.build_absolute_uri(instance.get_absolute_url())
        except NoReverseMatch:
            url = request.build_absolute_uri(reverse('dashboard'))

        reason = "abusive"
        other = "model: {}, app_label: {}, pk: {}".format(model, app_label, pk)
        send_abuse_report(url, reason, other, request.user.get_profile())
        return render_to_response('abuse/report_received.html', {},
                                  context_instance=RequestContext(request))
    else:
        form = AbuseForm()
    return render_to_response('abuse/report_abuse.html', {
        'form': form,
        'model': model,
        'app_label': app_label,
        'pk': pk,
    },
                              context_instance=RequestContext(request))
コード例 #2
0
ファイル: views.py プロジェクト: jvillalobos/zamboni
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(profile.get_url_path())
    else:
        return jingo.render(request, "account/abuse.html", {"abuse_form": form, "profile": profile})
コード例 #3
0
ファイル: views.py プロジェクト: BavarianTomcat/olympia
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})
コード例 #4
0
ファイル: views.py プロジェクト: dbialer/zamboni
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})
コード例 #5
0
ファイル: views.py プロジェクト: hardikj/zamboni
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())
コード例 #6
0
ファイル: views.py プロジェクト: peterkinalex/olympia
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})
コード例 #7
0
ファイル: views.py プロジェクト: MaxDumont/zamboni
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})
コード例 #8
0
ファイル: views.py プロジェクト: dbialer/zamboni
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]))
コード例 #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 render(request, 'users/report_abuse_full.html',
                      {'profile': user, 'abuse_form': form})
    return redirect(user.get_url_path())
コード例 #10
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(profile.get_url_path())
    else:
        return jingo.render(request, 'account/abuse.html',
                            {'abuse_form': form, 'profile': profile})
コード例 #11
0
ファイル: views.py プロジェクト: MaxDumont/zamboni
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})
コード例 #12
0
ファイル: views.py プロジェクト: steekid/zamboni
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())
コード例 #13
0
ファイル: views.py プロジェクト: MechanisM/zamboni
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, })
コード例 #14
0
ファイル: views.py プロジェクト: jvillalobos/zamboni
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, })
コード例 #15
0
ファイル: views.py プロジェクト: dimonov/zamboni
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]))
コード例 #16
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]))
コード例 #17
0
ファイル: views.py プロジェクト: sarasan/zamboni
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
        })
コード例 #18
0
ファイル: views.py プロジェクト: p2pu/lernanta
def prompt_abuse_reason(request):
    form = AbuseReasonForm(request.POST)
    if form.is_valid():
        # report abuse
        abuse_url = form.cleaned_data.get("url")
        reason = form.cleaned_data.get("reason")
        other = form.cleaned_data.get("other")
        send_abuse_report(abuse_url, reason, other, request.user.get_profile())
        messages.success(request, _("Thank you for filing an abuse report!"))
        return http.HttpResponseRedirect(abuse_url)

    context = {"form": form}
    return render_to_response("abuse/abuse_reason.html", context, context_instance=RequestContext(request))
コード例 #19
0
ファイル: views.py プロジェクト: lauraxt/zamboni
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})
コード例 #20
0
def prompt_abuse_reason(request):
    form = AbuseReasonForm(request.POST)
    if form.is_valid():
        # report abuse
        abuse_url = form.cleaned_data.get('url')
        reason = form.cleaned_data.get('reason')
        other = form.cleaned_data.get('other')
        send_abuse_report(abuse_url, reason, other, request.user.get_profile())
        messages.success(request, _("Thank you for filing an abuse report!"))
        return http.HttpResponseRedirect(abuse_url)

    context = {'form': form}
    return render_to_response('abuse/abuse_reason.html',
                              context,
                              context_instance=RequestContext(request))
コード例 #21
0
ファイル: views.py プロジェクト: p2pu/lernanta
def report_abuse(request, model, app_label, pk):
    """Report abusive or irrelavent content."""
    if request.method == "POST":
        # we only use the form for the csrf middleware. skip validation.
        form = AbuseForm(request.POST)
        content_type_cls = get_object_or_404(ContentType, model=model, app_label=app_label).model_class()
        instance = get_object_or_404(content_type_cls, pk=pk)
        try:
            url = request.build_absolute_uri(instance.get_absolute_url())
        except NoReverseMatch:
            url = request.build_absolute_uri(reverse("dashboard"))

        reason = "abusive"
        other = "model: {}, app_label: {}, pk: {}".format(model, app_label, pk)
        send_abuse_report(url, reason, other, request.user.get_profile())
        return render_to_response("abuse/report_received.html", {}, context_instance=RequestContext(request))
    else:
        form = AbuseForm()
    return render_to_response(
        "abuse/report_abuse.html",
        {"form": form, "model": model, "app_label": app_label, "pk": pk},
        context_instance=RequestContext(request),
    )