forked from mirrors/bookwyrm
Filter reports by server
This commit is contained in:
parent
96ea2b4477
commit
62cbfe0fac
3 changed files with 29 additions and 4 deletions
|
@ -1,8 +1,21 @@
|
|||
{% extends 'settings/admin_layout.html' %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block title %}{% trans "Reports" %}{% endblock %}
|
||||
{% block header %}{% trans "Reports" %}{% endblock %}
|
||||
{% block title %}
|
||||
{% if server %}
|
||||
{% blocktrans with server_name=server.server_name %}Reports: {{ server_name }}{% endblocktrans %}
|
||||
{% else %}
|
||||
{% trans "Reports" %}
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
{% block header %}
|
||||
{% if server %}
|
||||
{% blocktrans with server_name=server.server_name %}Reports: <small>{{ server_name }}</small>{% endblocktrans %}
|
||||
<a href="{% url 'settings-reports' %}" class="help has-text-weight-normal">Clear filters</a>
|
||||
{% else %}
|
||||
{% trans "Reports" %}
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
{% block panel %}
|
||||
<div class="tabs">
|
||||
|
@ -17,6 +30,10 @@
|
|||
</div>
|
||||
|
||||
<div class="block">
|
||||
{% if not reports %}
|
||||
<em>{% trans "No reports found." %}</em>
|
||||
{% endif %}
|
||||
|
||||
{% for report in reports %}
|
||||
<div class="block">
|
||||
{% include 'moderation/report_preview.html' with report=report %}
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
<dt>{% trans "Reports:" %}</dt>
|
||||
<dd>
|
||||
{{ reports.count }}
|
||||
{# {% if server.user_set.count %}(<a href="{% url 'settings-users' server=server.id %}">{% trans "View all users" %}</a>){% endif %} #}
|
||||
{% if reports.count %}(<a href="{% url 'settings-reports' %}?server={{ server.id }}">{% trans "View all" %}</a>){% endif %}
|
||||
</dd>
|
||||
</div>
|
||||
<div class="is-flex">
|
||||
|
|
|
@ -24,10 +24,18 @@ class Reports(View):
|
|||
|
||||
def get(self, request):
|
||||
""" view current reports """
|
||||
filters = {}
|
||||
|
||||
resolved = request.GET.get("resolved") == "true"
|
||||
server = request.GET.get("server")
|
||||
if server:
|
||||
server = get_object_or_404(models.FederatedServer, id=server)
|
||||
filters["user__federated_server"] = server
|
||||
filters["resolved"] = resolved
|
||||
data = {
|
||||
"resolved": resolved,
|
||||
"reports": models.Report.objects.filter(resolved=resolved),
|
||||
"server": server,
|
||||
"reports": models.Report.objects.filter(**filters),
|
||||
}
|
||||
return TemplateResponse(request, "moderation/reports.html", data)
|
||||
|
||||
|
|
Loading…
Reference in a new issue