Merge pull request #2843 from bookwyrm-social/user-reports-link

Show all (not just open) reports when linked from user admin
This commit is contained in:
Mouse Reeve 2023-05-15 06:04:42 -07:00 committed by GitHub
commit 24d59315df
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 12 additions and 5 deletions

View file

@ -21,10 +21,10 @@
{% block panel %}
<div class="tabs">
<ul>
<li class="{% if not resolved %}is-active{% endif %}"{% if not resolved == 'open' %} aria-current="page"{% endif %}>
<li class="{% if not resolved %}is-active{% endif %}"{% if not resolved %} aria-current="page"{% endif %}>
<a href="{% url 'settings-reports' %}?resolved=false">{% trans "Open" %}</a>
</li>
<li class="{% if resolved %}is-active{% endif %}"{% if resolved %} aria-current="page"{% endif %}>
<li class="{% if resolved and resolved != "all" %}is-active{% endif %}"{% if resolved and resolved != "all" %} aria-current="page"{% endif %}>
<a href="{% url 'settings-reports' %}?resolved=true">{% trans "Resolved" %}</a>
</li>
</ul>

View file

@ -61,7 +61,7 @@
<dd>
{{ report_count|intcomma }}
{% if report_count > 0 %}
<a href="{% url 'settings-reports' %}?username={{ user.username }}">
<a href="{% url 'settings-reports' %}?username={{ user.username }}&resolved=all">
{% trans "(View reports)" %}
</a>
{% endif %}

View file

@ -18,6 +18,7 @@ def validate_html(html):
for e in errors.split("\n")
if "&book" not in e
and "&type" not in e
and "&resolved" not in e
and "id and name attribute" not in e
and "illegal characters found in URI" not in e
and "escaping malformed URI reference" not in e

View file

@ -29,13 +29,19 @@ class ReportsAdmin(View):
"""view current reports"""
filters = {}
# we sometimes want to see all reports, regardless of resolution
if request.GET.get("resolved") == "all":
resolved = "all"
else:
resolved = request.GET.get("resolved") == "true"
server = request.GET.get("server")
if server:
filters["user__federated_server__server_name"] = server
username = request.GET.get("username")
if username:
filters["user__username__icontains"] = username
if resolved != "all":
filters["resolved"] = resolved
reports = models.Report.objects.filter(**filters)