mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-12-29 03:20:32 +00:00
Allow reports with no associated user
This commit is contained in:
parent
0be4fec167
commit
4f386e8c4e
8 changed files with 43 additions and 10 deletions
|
@ -45,7 +45,8 @@ def moderation_report_email(report):
|
|||
"""a report was created"""
|
||||
data = email_data()
|
||||
data["reporter"] = report.reporter.localname or report.reporter.username
|
||||
data["reportee"] = report.user.localname or report.user.username
|
||||
if report.user:
|
||||
data["reportee"] = report.user.localname or report.user.username
|
||||
data["report_link"] = report.remote_id
|
||||
|
||||
for admin in models.User.objects.filter(
|
||||
|
|
|
@ -11,7 +11,7 @@ class Report(BookWyrmModel):
|
|||
"User", related_name="reporter", on_delete=models.PROTECT
|
||||
)
|
||||
note = models.TextField(null=True, blank=True)
|
||||
user = models.ForeignKey("User", on_delete=models.PROTECT)
|
||||
user = models.ForeignKey("User", on_delete=models.PROTECT, null=True, blank=True)
|
||||
status = models.ForeignKey(
|
||||
"Status",
|
||||
null=True,
|
||||
|
|
|
@ -3,7 +3,19 @@
|
|||
|
||||
{% block content %}
|
||||
<p>
|
||||
{% blocktrans %}@{{ reporter }} has flagged behavior by @{{ reportee }} for moderation. {% endblocktrans %}
|
||||
{% if report_link %}
|
||||
|
||||
{% blocktrans trimmed %}
|
||||
@{{ reporter }} has flagged a link domain for moderation.
|
||||
{% endblocktrans %}
|
||||
|
||||
{% else %}
|
||||
|
||||
{% blocktrans trimmed %}
|
||||
@{{ reporter }} has flagged behavior by @{{ reportee }} for moderation.
|
||||
{% endblocktrans %}
|
||||
|
||||
{% endif %}
|
||||
</p>
|
||||
|
||||
{% trans "View report" as text %}
|
||||
|
|
|
@ -2,7 +2,15 @@
|
|||
{% load i18n %}
|
||||
{% block content %}
|
||||
|
||||
{% blocktrans %}@{{ reporter}} has flagged behavior by @{{ reportee }} for moderation. {% endblocktrans %}
|
||||
{% if report_link %}
|
||||
{% blocktrans trimmed %}
|
||||
@{{ reporter }} has flagged a link domain for moderation.
|
||||
{% endblocktrans %}
|
||||
{% else %}
|
||||
{% blocktrans trimmed %}
|
||||
@{{ reporter }} has flagged behavior by @{{ reportee }} for moderation.
|
||||
{% endblocktrans %}
|
||||
{% endif %}
|
||||
|
||||
{% trans "View report" %}
|
||||
{{ report_link }}
|
||||
|
|
|
@ -55,9 +55,11 @@
|
|||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if report.user %}
|
||||
{% include 'settings/users/user_info.html' with user=report.user %}
|
||||
|
||||
{% include 'settings/users/user_moderation_actions.html' with user=report.user %}
|
||||
{% endif %}
|
||||
|
||||
<div class="block">
|
||||
<h3 class="title is-4">{% trans "Moderator Comments" %}</h3>
|
||||
|
|
|
@ -9,9 +9,15 @@ Report #{{ report_id }}: Status posted by @{{ username }}
|
|||
|
||||
{% elif report.links.exists %}
|
||||
|
||||
{% blocktrans trimmed with report_id=report.id username=report.user|username %}
|
||||
Report #{{ report_id }}: Link added by @{{ username }}
|
||||
{% endblocktrans %}
|
||||
{% if report.user %}
|
||||
{% blocktrans trimmed with report_id=report.id username=report.user|username %}
|
||||
Report #{{ report_id }}: Link added by @{{ username }}
|
||||
{% endblocktrans %}
|
||||
{% else %}
|
||||
{% blocktrans trimmed with report_id=report.id %}
|
||||
Report #{{ report_id }}: Link domain
|
||||
{% endblocktrans %}
|
||||
{% endif %}
|
||||
|
||||
{% else %}
|
||||
|
||||
|
|
|
@ -287,7 +287,7 @@ urlpatterns = [
|
|||
name="report-status",
|
||||
),
|
||||
re_path(
|
||||
r"^report/(?P<user_id>\d+)/link/(?P<link_id>\d+)?$",
|
||||
r"^report/link/(?P<link_id>\d+)?$",
|
||||
views.Report.as_view(),
|
||||
name="report-link",
|
||||
),
|
||||
|
|
|
@ -13,9 +13,13 @@ from bookwyrm import emailing, forms, models
|
|||
class Report(View):
|
||||
"""Make reports"""
|
||||
|
||||
def get(self, request, user_id, status_id=None, link_id=None):
|
||||
def get(self, request, user_id=None, status_id=None, link_id=None):
|
||||
"""static view of report modal"""
|
||||
data = {"user": get_object_or_404(models.User, id=user_id)}
|
||||
data = {"user": None}
|
||||
if user_id:
|
||||
# but normally we should have an error if the user is not found
|
||||
data["user"] = get_object_or_404(models.User, id=user_id)
|
||||
|
||||
if status_id:
|
||||
data["status"] = status_id
|
||||
if link_id:
|
||||
|
|
Loading…
Reference in a new issue