Merge pull request #2055 from bookwyrm-social/reports

Paginate reports
This commit is contained in:
Mouse Reeve 2022-03-24 11:35:48 -07:00 committed by GitHub
commit 6808b70d3f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 37 additions and 5 deletions

View file

@ -44,5 +44,6 @@
{% endfor %} {% endfor %}
</div> </div>
{% include 'snippets/pagination.html' with page=reports path=request.path %}
{% endblock %} {% endblock %}

View file

@ -61,10 +61,25 @@
</tr> </tr>
{% for user in users %} {% for user in users %}
<tr> <tr>
<td><a href="{% url 'settings-user' user.id %}">{{ user|username }}</a></td> <td class="overflow-wrap-anywhere">
<a href="{% url 'settings-user' user.id %}">{{ user|username }}</a>
</td>
<td>{{ user.created_date }}</td> <td>{{ user.created_date }}</td>
<td>{{ user.last_active_date }}</td> <td>{{ user.last_active_date }}</td>
<td>{% if user.is_active %}{% trans "Active" %}{% else %}{% trans "Inactive" %}{% endif %}</td> <td>
{% if user.is_active %}
<span class="tag is-success" aria-hidden="true">
<span class="icon icon-check"></span>
</span>
{% trans "Active" %}
{% else %}
<span class="tag is-warning" aria-hidden="true">
<span class="icon icon-x"></span>
</span>
{% trans "Inactive" %}
<span class="help">({{ user.get_deactivation_reason_display }})</span>
{% endif %}
</td>
{% if status != "local" %} {% if status != "local" %}
<td> <td>
{% if user.federated_server %} {% if user.federated_server %}

View file

@ -6,7 +6,7 @@
<div class="column is-flex is-flex-direction-column"> <div class="column is-flex is-flex-direction-column">
<h4 class="title is-4">{% trans "Profile" %}</h4> <h4 class="title is-4">{% trans "Profile" %}</h4>
<div class="box is-flex-grow-1"> <div class="box is-flex-grow-1">
{% include 'user/user_preview.html' with user=user %} {% include 'user/user_preview.html' with user=user admin_mode=True %}
{% if user.summary %} {% if user.summary %}
<div class="box content has-background-secondary is-shadowless"> <div class="box content has-background-secondary is-shadowless">
{{ user.summary|to_markdown|safe }} {{ user.summary|to_markdown|safe }}
@ -14,6 +14,10 @@
{% endif %} {% endif %}
<p class="mt-2"><a href="{{ user.local_path }}">{% trans "View user profile" %}</a></p> <p class="mt-2"><a href="{{ user.local_path }}">{% trans "View user profile" %}</a></p>
{% url 'settings-user' user.id as url %}
{% if not request.path == url %}
<p class="mt-2"><a href="{{ url }}">{% trans "Go to user admin" %}</a></p>
{% endif %}
</div> </div>
</div> </div>
<div class="column is-flex is-flex-direction-column is-4"> <div class="column is-flex is-flex-direction-column is-4">
@ -67,6 +71,9 @@
<dt class="is-pulled-left mr-5">{% trans "Blocked by count:" %}</dt> <dt class="is-pulled-left mr-5">{% trans "Blocked by count:" %}</dt>
<dd>{{ user.blocked_by.count }}</dd> <dd>{{ user.blocked_by.count }}</dd>
<dt class="is-pulled-left mr-5">{% trans "Date added:" %}</dt>
<dd>{{ user.created_date }}</dd>
<dt class="is-pulled-left mr-5">{% trans "Last active date:" %}</dt> <dt class="is-pulled-left mr-5">{% trans "Last active date:" %}</dt>
<dd>{{ user.last_active_date }}</dd> <dd>{{ user.last_active_date }}</dd>

View file

@ -21,7 +21,7 @@
<p><a href="{{ user.remote_id }}">{{ user.username }}</a></p> <p><a href="{{ user.remote_id }}">{{ user.username }}</a></p>
<p>{% blocktrans with date=user.created_date|naturaltime %}Joined {{ date }}{% endblocktrans %}</p> <p>{% blocktrans with date=user.created_date|naturaltime %}Joined {{ date }}{% endblocktrans %}</p>
<p> <p>
{% if request.user.id == user.id %} {% if request.user.id == user.id or admin_mode %}
<a href="{% url 'user-followers' user|username %}">{% blocktrans count counter=user.followers.count %}{{ counter }} follower{% plural %}{{ counter }} followers{% endblocktrans %}</a>, <a href="{% url 'user-followers' user|username %}">{% blocktrans count counter=user.followers.count %}{{ counter }} follower{% plural %}{{ counter }} followers{% endblocktrans %}</a>,
<a href="{% url 'user-following' user|username %}">{% blocktrans with counter=user.following.count %}{{ counter }} following{% endblocktrans %}</a> <a href="{% url 'user-following' user|username %}">{% blocktrans with counter=user.following.count %}{{ counter }} following{% endblocktrans %}</a>

View file

@ -1,5 +1,6 @@
""" moderation via flagged posts and users """ """ moderation via flagged posts and users """
from django.contrib.auth.decorators import login_required, permission_required from django.contrib.auth.decorators import login_required, permission_required
from django.core.paginator import Paginator
from django.core.exceptions import PermissionDenied from django.core.exceptions import PermissionDenied
from django.shortcuts import get_object_or_404, redirect from django.shortcuts import get_object_or_404, redirect
from django.template.response import TemplateResponse from django.template.response import TemplateResponse
@ -7,6 +8,7 @@ from django.utils.decorators import method_decorator
from django.views import View from django.views import View
from bookwyrm import forms, models from bookwyrm import forms, models
from bookwyrm.settings import PAGE_LENGTH
# pylint: disable=no-self-use # pylint: disable=no-self-use
@ -34,10 +36,17 @@ class ReportsAdmin(View):
if username: if username:
filters["user__username__icontains"] = username filters["user__username__icontains"] = username
filters["resolved"] = resolved filters["resolved"] = resolved
reports = models.Report.objects.filter(**filters)
paginated = Paginator(reports, PAGE_LENGTH)
page = paginated.get_page(request.GET.get("page"))
data = { data = {
"resolved": resolved, "resolved": resolved,
"server": server, "server": server,
"reports": models.Report.objects.filter(**filters), "reports": page,
"page_range": paginated.get_elided_page_range(
page.number, on_each_side=2, on_ends=1
),
} }
return TemplateResponse(request, "settings/reports/reports.html", data) return TemplateResponse(request, "settings/reports/reports.html", data)