mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-23 10:01:04 +00:00
Comments on reports
This commit is contained in:
parent
46581e37e2
commit
9245b9d9ca
3 changed files with 36 additions and 6 deletions
|
@ -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",)
|
||||
|
|
|
@ -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 %}
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="block">
|
||||
<h3 class="title is-4">{% trans "Moderator Comments" %}</h3>
|
||||
{% for comment in report.reportcomment_set.all %}
|
||||
<div class="block">
|
||||
{{ comment }}
|
||||
<div class="card block">
|
||||
<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>
|
||||
{% 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>
|
||||
<textarea name="comment" id="report_comment" class="textarea"></textarea>
|
||||
<textarea name="note" id="report_comment" class="textarea"></textarea>
|
||||
<button class="button">{% trans "Comment" %}</button>
|
||||
</forM=m>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div class="block">
|
||||
|
|
|
@ -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")
|
||||
|
|
Loading…
Reference in a new issue