From 951b611881a800107143f01d25601c7b69c01f51 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Thu, 24 Mar 2022 10:40:42 -0700 Subject: [PATCH 1/4] Paginates results --- bookwyrm/templates/settings/reports/reports.html | 1 + bookwyrm/views/admin/reports.py | 11 ++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/bookwyrm/templates/settings/reports/reports.html b/bookwyrm/templates/settings/reports/reports.html index 99cca1a75..64db2f26b 100644 --- a/bookwyrm/templates/settings/reports/reports.html +++ b/bookwyrm/templates/settings/reports/reports.html @@ -44,5 +44,6 @@ {% endfor %} +{% include 'snippets/pagination.html' with page=reports path=request.path %} {% endblock %} diff --git a/bookwyrm/views/admin/reports.py b/bookwyrm/views/admin/reports.py index bf9553e52..c19e3db4a 100644 --- a/bookwyrm/views/admin/reports.py +++ b/bookwyrm/views/admin/reports.py @@ -1,5 +1,6 @@ """ moderation via flagged posts and users """ from django.contrib.auth.decorators import login_required, permission_required +from django.core.paginator import Paginator from django.core.exceptions import PermissionDenied from django.shortcuts import get_object_or_404, redirect from django.template.response import TemplateResponse @@ -7,6 +8,7 @@ from django.utils.decorators import method_decorator from django.views import View from bookwyrm import forms, models +from bookwyrm.settings import PAGE_LENGTH # pylint: disable=no-self-use @@ -34,10 +36,17 @@ class ReportsAdmin(View): if username: filters["user__username__icontains"] = username filters["resolved"] = resolved + + reports = models.Report.objects.filter(**filters) + paginated = Paginator(reports, PAGE_LENGTH) + page = paginated.get_page(request.GET.get("page")) data = { "resolved": resolved, "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) From 533642bf7e7ff23d85f476180240a47998863970 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Thu, 24 Mar 2022 10:43:17 -0700 Subject: [PATCH 2/4] Adds link to admin view --- bookwyrm/templates/settings/users/user_info.html | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bookwyrm/templates/settings/users/user_info.html b/bookwyrm/templates/settings/users/user_info.html index a5447931c..81b3a219b 100644 --- a/bookwyrm/templates/settings/users/user_info.html +++ b/bookwyrm/templates/settings/users/user_info.html @@ -14,6 +14,10 @@ {% endif %}

{% trans "View user profile" %}

+ {% url 'settings-user' user.id as url %} + {% if not request.path == url %} +

{% trans "Go to user admin" %}

+ {% endif %}
From 82f87a3ff59f1cc6bd28dbfb037df3bda24913a8 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Thu, 24 Mar 2022 10:55:32 -0700 Subject: [PATCH 3/4] Adds colored icon for user status in admin table --- .../templates/settings/users/user_admin.html | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/bookwyrm/templates/settings/users/user_admin.html b/bookwyrm/templates/settings/users/user_admin.html index fdd9fb7df..4144f0bde 100644 --- a/bookwyrm/templates/settings/users/user_admin.html +++ b/bookwyrm/templates/settings/users/user_admin.html @@ -61,10 +61,25 @@ {% for user in users %} - {{ user|username }} + + {{ user|username }} + {{ user.created_date }} {{ user.last_active_date }} - {% if user.is_active %}{% trans "Active" %}{% else %}{% trans "Inactive" %}{% endif %} + + {% if user.is_active %} + + {% trans "Active" %} + {% else %} + + {% trans "Inactive" %} + ({{ user.get_deactivation_reason_display }}) + {% endif %} + {% if status != "local" %} {% if user.federated_server %} From 0166cca0b75d841633af936d9c40f11c8522fad0 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Thu, 24 Mar 2022 11:01:02 -0700 Subject: [PATCH 4/4] Show created date and follower counts in admin view Adds "admin_mode" to user_preview --- bookwyrm/templates/settings/users/user_info.html | 5 ++++- bookwyrm/templates/user/user_preview.html | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/bookwyrm/templates/settings/users/user_info.html b/bookwyrm/templates/settings/users/user_info.html index 81b3a219b..a04db3b8e 100644 --- a/bookwyrm/templates/settings/users/user_info.html +++ b/bookwyrm/templates/settings/users/user_info.html @@ -6,7 +6,7 @@

{% trans "Profile" %}

- {% include 'user/user_preview.html' with user=user %} + {% include 'user/user_preview.html' with user=user admin_mode=True %} {% if user.summary %}
{{ user.summary|to_markdown|safe }} @@ -71,6 +71,9 @@
{% trans "Blocked by count:" %}
{{ user.blocked_by.count }}
+
{% trans "Date added:" %}
+
{{ user.created_date }}
+
{% trans "Last active date:" %}
{{ user.last_active_date }}
diff --git a/bookwyrm/templates/user/user_preview.html b/bookwyrm/templates/user/user_preview.html index 0ed7c8ccd..c6bc180cb 100755 --- a/bookwyrm/templates/user/user_preview.html +++ b/bookwyrm/templates/user/user_preview.html @@ -21,7 +21,7 @@

{{ user.username }}

{% blocktrans with date=user.created_date|naturaltime %}Joined {{ date }}{% endblocktrans %}

- {% if request.user.id == user.id %} + {% if request.user.id == user.id or admin_mode %} {% blocktrans count counter=user.followers.count %}{{ counter }} follower{% plural %}{{ counter }} followers{% endblocktrans %}, {% blocktrans with counter=user.following.count %}{{ counter }} following{% endblocktrans %}