From 5bb001e15f1885aeeda8cd5d9c82a46bf65885de Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Fri, 8 Jul 2022 09:10:29 -0700 Subject: [PATCH 1/3] Show avatars in user admin view I find this helpful as a rough hueristic for how engaged a user is -- if they've never added an avatar, it's often the case that they never really got further in to using the app than just registering a username. Also, on one occassion, a user had an avatar that violated the instance ToS, which would have been handy to see at a glance in this list. --- bookwyrm/templates/settings/users/user_admin.html | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/bookwyrm/templates/settings/users/user_admin.html b/bookwyrm/templates/settings/users/user_admin.html index 059e064db..5b2fbd15f 100644 --- a/bookwyrm/templates/settings/users/user_admin.html +++ b/bookwyrm/templates/settings/users/user_admin.html @@ -36,7 +36,7 @@ {% url 'settings-users' as url %} - @@ -61,7 +61,10 @@ {% for user in users %} - + From be86fef42d6c357a4629b6bc75e5b489c6cd8ccd Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Fri, 8 Jul 2022 09:19:48 -0700 Subject: [PATCH 2/3] Move deleted users to a separate tab Since there's nothing to be done with them, they get their own tab. --- bookwyrm/templates/settings/users/user_admin.html | 8 ++++++-- bookwyrm/urls.py | 2 +- bookwyrm/views/admin/user_admin.py | 14 +++++++++----- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/bookwyrm/templates/settings/users/user_admin.html b/bookwyrm/templates/settings/users/user_admin.html index 5b2fbd15f..9bc5805b1 100644 --- a/bookwyrm/templates/settings/users/user_admin.html +++ b/bookwyrm/templates/settings/users/user_admin.html @@ -24,6 +24,10 @@
  • {% trans "Local users" %}
  • + {% url 'settings-users' status="deleted" as url %} +
  • + {% trans "Deleted users" %} +
  • {% url 'settings-users' status="federated" as url %}
  • {% trans "Federated community" %} @@ -52,7 +56,7 @@ {% trans "Status" as text %} {% include 'snippets/table-sort-header.html' with field="is_active" sort=sort text=text %} - {% if status != "local" %} + {% if status == "federated" %}
  • + {% trans "Username" as text %} {% include 'snippets/table-sort-header.html' with field="username" sort=sort text=text %}
    + + {% include 'snippets/avatar.html' with user=user %} + {{ user|username }} {{ user.created_date }} {% trans "Remote instance" as text %} {% include 'snippets/table-sort-header.html' with field="federated_server__server_name" sort=sort text=text %} @@ -89,7 +93,7 @@ ({{ user.get_deactivation_reason_display }}) {% endif %} - {% if status != "local" %} + {% if status == "federated" %} {% if user.federated_server %} {{ user.federated_server.server_name }} diff --git a/bookwyrm/urls.py b/bookwyrm/urls.py index 248bb6db8..cbb468d5a 100644 --- a/bookwyrm/urls.py +++ b/bookwyrm/urls.py @@ -126,7 +126,7 @@ urlpatterns = [ r"^settings/users/?$", views.UserAdminList.as_view(), name="settings-users" ), re_path( - r"^settings/users/(?P(local|federated))\/?$", + r"^settings/users/(?P(local|federated|deleted))\/?$", views.UserAdminList.as_view(), name="settings-users", ), diff --git a/bookwyrm/views/admin/user_admin.py b/bookwyrm/views/admin/user_admin.py index aba665d2f..6ec6f93d2 100644 --- a/bookwyrm/views/admin/user_admin.py +++ b/bookwyrm/views/admin/user_admin.py @@ -22,21 +22,25 @@ class UserAdminList(View): def get(self, request, status="local"): """list of users""" filters = {} + exclusions = {} if server := request.GET.get("server"): server = models.FederatedServer.objects.filter(server_name=server).first() filters["federated_server"] = server filters["federated_server__isnull"] = False + if username := request.GET.get("username"): filters["username__icontains"] = username - scope = request.GET.get("scope") - if scope and scope == "local": - filters["local"] = True + if email := request.GET.get("email"): filters["email__endswith"] = email - filters["local"] = status == "local" + filters["local"] = status in ["local", "deleted"] + if status == "deleted": + filters["deactivation_reason__icontains"] = "deletion" + else: + exclusions["deactivation_reason__icontains"] = "deletion" - users = models.User.objects.filter(**filters) + users = models.User.objects.filter(**filters).exclude(**exclusions) sort = request.GET.get("sort", "-created_date") sort_fields = [ From 65f55fe324a14c6914497409a77bd4abbc15b233 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Fri, 8 Jul 2022 09:26:11 -0700 Subject: [PATCH 3/3] Fixes link to remote instance user list --- bookwyrm/templates/settings/federation/instance.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bookwyrm/templates/settings/federation/instance.html b/bookwyrm/templates/settings/federation/instance.html index cb6b1fc37..0064c4ff3 100644 --- a/bookwyrm/templates/settings/federation/instance.html +++ b/bookwyrm/templates/settings/federation/instance.html @@ -56,7 +56,7 @@
    {% trans "Users:" %}
    {{ users.count }} - {% if server.user_set.count %}({% trans "View all" %}){% endif %} + {% if server.user_set.count %}({% trans "View all" %}){% endif %}
    {% trans "Reports:" %}