From 9245b9d9caeccba90c7b7afb62af1269d6ffca59 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Fri, 12 Mar 2021 15:56:54 -0800 Subject: [PATCH] Comments on reports --- bookwyrm/models/report.py | 5 +++++ bookwyrm/templates/moderation/report.html | 23 ++++++++++++++++++----- bookwyrm/views/reports.py | 14 +++++++++++++- 3 files changed, 36 insertions(+), 6 deletions(-) diff --git a/bookwyrm/models/report.py b/bookwyrm/models/report.py index 8893f42fc..a1e17eb2f 100644 --- a/bookwyrm/models/report.py +++ b/bookwyrm/models/report.py @@ -30,3 +30,8 @@ class ReportComment(BookWyrmModel): user = models.ForeignKey("User", on_delete=models.PROTECT) note = models.TextField() report = models.ForeignKey(Report, on_delete=models.PROTECT) + + class Meta: + """ sort comments """ + + ordering = ("-created_date",) diff --git a/bookwyrm/templates/moderation/report.html b/bookwyrm/templates/moderation/report.html index ae014d68c..d27695446 100644 --- a/bookwyrm/templates/moderation/report.html +++ b/bookwyrm/templates/moderation/report.html @@ -1,5 +1,6 @@ {% extends 'settings/admin_layout.html' %} {% load i18n %} +{% load humanize %} {% block title %}{% blocktrans with report_id=report.id %}Report #{{ report_id }}{% endblocktrans %}{% endblock %} {% block header %}{% blocktrans with report_id=report.id %}Report #{{ report_id }}{% endblocktrans %}{% endblock %} @@ -29,17 +30,29 @@ {% endif %} + +
+

{% trans "Moderator Comments" %}

{% for comment in report.reportcomment_set.all %} -
- {{ comment }} +
+

{{ comment.note }}

+
{% endfor %} -
+ + {% csrf_token %} - + - +
diff --git a/bookwyrm/views/reports.py b/bookwyrm/views/reports.py index 2ba0d27ac..06909cf11 100644 --- a/bookwyrm/views/reports.py +++ b/bookwyrm/views/reports.py @@ -46,9 +46,21 @@ class Report(View): def get(self, request, report_id): """ load a report """ - data = {"report": get_object_or_404(models.Report, id=report_id)} + data = { + "report": get_object_or_404(models.Report, id=report_id), + } return TemplateResponse(request, "moderation/report.html", data) + def post(self, request, report_id): + """ comment on a report """ + report = get_object_or_404(models.Report, id=report_id) + models.ReportComment.objects.create( + user=request.user, + report=report, + note=request.POST.get("note"), + ) + return redirect("settings-report", report.id) + @login_required @permission_required("bookwyrm_moderate_user")