Show all (not just open) reports when linked from user admin

This commit is contained in:
Mouse Reeve 2023-05-07 09:50:24 -07:00
parent 7211906697
commit 912e92bacd
3 changed files with 11 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

@ -29,14 +29,20 @@ class ReportsAdmin(View):
"""view current reports"""
filters = {}
resolved = request.GET.get("resolved") == "true"
# 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
filters["resolved"] = resolved
if resolved != "all":
filters["resolved"] = resolved
reports = models.Report.objects.filter(**filters)
paginated = Paginator(reports, PAGE_LENGTH)