Comments on reports

This commit is contained in:
Mouse Reeve 2021-03-12 15:56:54 -08:00
parent 46581e37e2
commit 9245b9d9ca
3 changed files with 36 additions and 6 deletions

View file

@ -30,3 +30,8 @@ class ReportComment(BookWyrmModel):
user = models.ForeignKey("User", on_delete=models.PROTECT) user = models.ForeignKey("User", on_delete=models.PROTECT)
note = models.TextField() note = models.TextField()
report = models.ForeignKey(Report, on_delete=models.PROTECT) report = models.ForeignKey(Report, on_delete=models.PROTECT)
class Meta:
""" sort comments """
ordering = ("-created_date",)

View file

@ -1,5 +1,6 @@
{% extends 'settings/admin_layout.html' %} {% extends 'settings/admin_layout.html' %}
{% load i18n %} {% load i18n %}
{% load humanize %}
{% block title %}{% blocktrans with report_id=report.id %}Report #{{ report_id }}{% endblocktrans %}{% endblock %} {% 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 %} {% block header %}{% blocktrans with report_id=report.id %}Report #{{ report_id }}{% endblocktrans %}{% endblock %}
@ -29,17 +30,29 @@
{% endif %} {% endif %}
</form> </form>
</div> </div>
</div>
<div class="block">
<h3 class="title is-4">{% trans "Moderator Comments" %}</h3>
{% for comment in report.reportcomment_set.all %} {% for comment in report.reportcomment_set.all %}
<div class="block"> <div class="card block">
{{ comment }} <p class="card-content">{{ comment.note }}</p>
<div class="card-footer">
<div class="card-footer-item">
<a href="{{ comment.user.local_path }}">{{ comment.user.display_name }}</a>
</div>
<div class="card-footer-item">
{{ comment.created_date | naturaltime }}
</div>
</div>
</div> </div>
{% endfor %} {% endfor %}
<form> <form class="block" name="report-comment" method="post" action="{% url 'settings-report' report.id %}">
{% csrf_token %}
<label for="report_comment" class="label">Comment on report</label> <label for="report_comment" class="label">Comment on report</label>
<textarea name="comment" id="report_comment" class="textarea"></textarea> <textarea name="note" id="report_comment" class="textarea"></textarea>
<button class="button">{% trans "Comment" %}</button> <button class="button">{% trans "Comment" %}</button>
</forM=m> </form>
</div> </div>
<div class="block"> <div class="block">

View file

@ -46,9 +46,21 @@ class Report(View):
def get(self, request, report_id): def get(self, request, report_id):
""" load a report """ """ 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) 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 @login_required
@permission_required("bookwyrm_moderate_user") @permission_required("bookwyrm_moderate_user")