mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2025-01-03 13:58:43 +00:00
Merge pull request #2199 from bookwyrm-social/user-admin-deleted
Move deleted users to separate tab in admin panel
This commit is contained in:
commit
4af0095237
4 changed files with 22 additions and 11 deletions
|
@ -56,7 +56,7 @@
|
|||
<dt class="is-pulled-left mr-5">{% trans "Users:" %}</dt>
|
||||
<dd>
|
||||
{{ users.count }}
|
||||
{% if server.user_set.count %}(<a href="{% url 'settings-users' %}?server={{ server.server_name }}">{% trans "View all" %}</a>){% endif %}
|
||||
{% if server.user_set.count %}(<a href="{% url 'settings-users' status="federated" %}?server={{ server.server_name }}">{% trans "View all" %}</a>){% endif %}
|
||||
</dd>
|
||||
|
||||
<dt class="is-pulled-left mr-5">{% trans "Reports:" %}</dt>
|
||||
|
|
|
@ -24,6 +24,10 @@
|
|||
<li {% if request.path in url %}class="is-active" aria-current="page"{% endif %}>
|
||||
<a href="{{ url }}">{% trans "Local users" %}</a>
|
||||
</li>
|
||||
{% url 'settings-users' status="deleted" as url %}
|
||||
<li {% if url in request.path %}class="is-active" aria-current="page"{% endif %}>
|
||||
<a href="{{ url }}">{% trans "Deleted users" %}</a>
|
||||
</li>
|
||||
{% url 'settings-users' status="federated" as url %}
|
||||
<li {% if url in request.path %}class="is-active" aria-current="page"{% endif %}>
|
||||
<a href="{{ url }}">{% trans "Federated community" %}</a>
|
||||
|
@ -36,7 +40,7 @@
|
|||
<table class="table is-striped is-fullwidth">
|
||||
<tr>
|
||||
{% url 'settings-users' as url %}
|
||||
<th>
|
||||
<th colspan="2">
|
||||
{% trans "Username" as text %}
|
||||
{% include 'snippets/table-sort-header.html' with field="username" sort=sort text=text %}
|
||||
</th>
|
||||
|
@ -52,7 +56,7 @@
|
|||
{% trans "Status" as text %}
|
||||
{% include 'snippets/table-sort-header.html' with field="is_active" sort=sort text=text %}
|
||||
</th>
|
||||
{% if status != "local" %}
|
||||
{% if status == "federated" %}
|
||||
<th>
|
||||
{% trans "Remote instance" as text %}
|
||||
{% include 'snippets/table-sort-header.html' with field="federated_server__server_name" sort=sort text=text %}
|
||||
|
@ -61,7 +65,10 @@
|
|||
</tr>
|
||||
{% for user in users %}
|
||||
<tr>
|
||||
<td class="overflow-wrap-anywhere">
|
||||
<td class="pr-0">
|
||||
{% include 'snippets/avatar.html' with user=user %}
|
||||
</td>
|
||||
<td class="overflow-wrap-anywhere pl-1">
|
||||
<a href="{% url 'settings-user' user.id %}">{{ user|username }}</a>
|
||||
</td>
|
||||
<td>{{ user.created_date }}</td>
|
||||
|
@ -86,7 +93,7 @@
|
|||
<span class="help">({{ user.get_deactivation_reason_display }})</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
{% if status != "local" %}
|
||||
{% if status == "federated" %}
|
||||
<td>
|
||||
{% if user.federated_server %}
|
||||
<a href="{% url 'settings-federated-server' user.federated_server.id %}">{{ user.federated_server.server_name }}</a>
|
||||
|
|
|
@ -126,7 +126,7 @@ urlpatterns = [
|
|||
r"^settings/users/?$", views.UserAdminList.as_view(), name="settings-users"
|
||||
),
|
||||
re_path(
|
||||
r"^settings/users/(?P<status>(local|federated))\/?$",
|
||||
r"^settings/users/(?P<status>(local|federated|deleted))\/?$",
|
||||
views.UserAdminList.as_view(),
|
||||
name="settings-users",
|
||||
),
|
||||
|
|
|
@ -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 = [
|
||||
|
|
Loading…
Reference in a new issue