Move deleted users to a separate tab

Since there's nothing to be done with them, they get their own tab.
This commit is contained in:
Mouse Reeve 2022-07-08 09:19:48 -07:00
parent 5bb001e15f
commit be86fef42d
3 changed files with 16 additions and 8 deletions

View file

@ -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>
@ -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 %}
@ -89,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>

View file

@ -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",
),

View file

@ -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 = [