Exemplo n.º 1
0
 def test_form(self):
     r = AbuseReportReason.objects.create(name="test reason")
     u = User.objects.create(username="******")
     description_text = "Some test description"
     AbuseReportForm = get_abuse_form_class(u)
     form = AbuseReportForm(data={"description": description_text, "content_object": u, "reason": r.pk})
     reason = form.save()
     self.assertIsInstance(reason, AbuseReport)
     self.assertEqual(reason.description, description_text)
     self.assertEqual(reason.content_object, u)
Exemplo n.º 2
0
 def test_form(self):
     r = AbuseReportReason.objects.create(name="test reason")
     u = User.objects.create(username="******")
     description_text = 'Some test description'
     AbuseReportForm = get_abuse_form_class(u)
     form = AbuseReportForm(data={
         'description': description_text,
         'content_object': u,
         'reason': r.pk
     })
     reason = form.save()
     self.assertIsInstance(reason, AbuseReport)
     self.assertEqual(reason.description, description_text)
     self.assertEqual(reason.content_object, u)
Exemplo n.º 3
0
def report_abuse(request, content_type, object_id):
	content_type = get_object_or_404(ContentType, pk=content_type)
	model = content_type.model_class()

	obj = get_object_or_404(model, pk=object_id)

	form = get_abuse_form_class(obj)(request.POST or None)


	if form.is_valid():
		report = form.save()
		messages.success(request, _('Thank you for submitting abuse report. Administrator has been notified and will review your report!'))
		return redirect(obj.get_absolute_url())

	return direct_to_template(request, "abuse_reports/form.html", locals())
Exemplo n.º 4
0
def report_abuse(request, content_type, object_id):
    content_type = get_object_or_404(ContentType, pk=content_type)
    model = content_type.model_class()

    obj = get_object_or_404(model, pk=object_id)

    form = get_abuse_form_class(obj)(request.POST or None)

    if form.is_valid():
        report = form.save()
        messages.success(
            request,
            _('Thank you for submitting abuse report. Administrator has been notified and will review your report!'
              ))
        return redirect(obj.get_absolute_url())

    return direct_to_template(request, "abuse_reports/form.html", locals())