mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2025-01-03 13:58:43 +00:00
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:
parent
5bb001e15f
commit
be86fef42d
3 changed files with 16 additions and 8 deletions
|
@ -24,6 +24,10 @@
|
||||||
<li {% if request.path in url %}class="is-active" aria-current="page"{% endif %}>
|
<li {% if request.path in url %}class="is-active" aria-current="page"{% endif %}>
|
||||||
<a href="{{ url }}">{% trans "Local users" %}</a>
|
<a href="{{ url }}">{% trans "Local users" %}</a>
|
||||||
</li>
|
</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 %}
|
{% url 'settings-users' status="federated" as url %}
|
||||||
<li {% if url in request.path %}class="is-active" aria-current="page"{% endif %}>
|
<li {% if url in request.path %}class="is-active" aria-current="page"{% endif %}>
|
||||||
<a href="{{ url }}">{% trans "Federated community" %}</a>
|
<a href="{{ url }}">{% trans "Federated community" %}</a>
|
||||||
|
@ -52,7 +56,7 @@
|
||||||
{% trans "Status" as text %}
|
{% trans "Status" as text %}
|
||||||
{% include 'snippets/table-sort-header.html' with field="is_active" sort=sort text=text %}
|
{% include 'snippets/table-sort-header.html' with field="is_active" sort=sort text=text %}
|
||||||
</th>
|
</th>
|
||||||
{% if status != "local" %}
|
{% if status == "federated" %}
|
||||||
<th>
|
<th>
|
||||||
{% trans "Remote instance" as text %}
|
{% trans "Remote instance" as text %}
|
||||||
{% include 'snippets/table-sort-header.html' with field="federated_server__server_name" sort=sort text=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>
|
<span class="help">({{ user.get_deactivation_reason_display }})</span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
{% if status != "local" %}
|
{% if status == "federated" %}
|
||||||
<td>
|
<td>
|
||||||
{% if user.federated_server %}
|
{% if user.federated_server %}
|
||||||
<a href="{% url 'settings-federated-server' user.federated_server.id %}">{{ user.federated_server.server_name }}</a>
|
<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"
|
r"^settings/users/?$", views.UserAdminList.as_view(), name="settings-users"
|
||||||
),
|
),
|
||||||
re_path(
|
re_path(
|
||||||
r"^settings/users/(?P<status>(local|federated))\/?$",
|
r"^settings/users/(?P<status>(local|federated|deleted))\/?$",
|
||||||
views.UserAdminList.as_view(),
|
views.UserAdminList.as_view(),
|
||||||
name="settings-users",
|
name="settings-users",
|
||||||
),
|
),
|
||||||
|
|
|
@ -22,21 +22,25 @@ class UserAdminList(View):
|
||||||
def get(self, request, status="local"):
|
def get(self, request, status="local"):
|
||||||
"""list of users"""
|
"""list of users"""
|
||||||
filters = {}
|
filters = {}
|
||||||
|
exclusions = {}
|
||||||
if server := request.GET.get("server"):
|
if server := request.GET.get("server"):
|
||||||
server = models.FederatedServer.objects.filter(server_name=server).first()
|
server = models.FederatedServer.objects.filter(server_name=server).first()
|
||||||
filters["federated_server"] = server
|
filters["federated_server"] = server
|
||||||
filters["federated_server__isnull"] = False
|
filters["federated_server__isnull"] = False
|
||||||
|
|
||||||
if username := request.GET.get("username"):
|
if username := request.GET.get("username"):
|
||||||
filters["username__icontains"] = username
|
filters["username__icontains"] = username
|
||||||
scope = request.GET.get("scope")
|
|
||||||
if scope and scope == "local":
|
|
||||||
filters["local"] = True
|
|
||||||
if email := request.GET.get("email"):
|
if email := request.GET.get("email"):
|
||||||
filters["email__endswith"] = 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 = request.GET.get("sort", "-created_date")
|
||||||
sort_fields = [
|
sort_fields = [
|
||||||
|
|
Loading…
Reference in a new issue