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))
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})
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})
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})
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())
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})
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})
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]))
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())
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})
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})
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())
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, })
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, })
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]))
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]))
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 })
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))
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})
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))
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), )