forked from mirrors/bookwyrm
Separate admin user list into tabbed lists
This commit is contained in:
parent
bf68b70fba
commit
488d702473
3 changed files with 71 additions and 40 deletions
|
@ -1,5 +1,7 @@
|
||||||
{% extends 'settings/layout.html' %}
|
{% extends 'settings/layout.html' %}
|
||||||
{% load i18n %}
|
{% load i18n %}
|
||||||
|
{% load utilities %}
|
||||||
|
|
||||||
{% block title %}{% trans "Users" %}{% endblock %}
|
{% block title %}{% trans "Users" %}{% endblock %}
|
||||||
|
|
||||||
{% block header %}
|
{% block header %}
|
||||||
|
@ -15,46 +17,67 @@
|
||||||
|
|
||||||
{% include 'settings/users/user_admin_filters.html' %}
|
{% include 'settings/users/user_admin_filters.html' %}
|
||||||
|
|
||||||
<table class="table is-striped">
|
<div class="block">
|
||||||
<tr>
|
<div class="tabs">
|
||||||
{% url 'settings-users' as url %}
|
<ul>
|
||||||
<th>
|
{% url 'settings-users' as url %}
|
||||||
{% trans "Username" as text %}
|
<li {% if request.path in url %}class="is-active" aria-current="page"{% endif %}>
|
||||||
{% include 'snippets/table-sort-header.html' with field="username" sort=sort text=text %}
|
<a href="{{ url }}">{% trans "Local users" %}</a>
|
||||||
</th>
|
</li>
|
||||||
<th>
|
{% url 'settings-users' status="federated" as url %}
|
||||||
{% trans "Date Added" as text %}
|
<li {% if url in request.path %}class="is-active" aria-current="page"{% endif %}>
|
||||||
{% include 'snippets/table-sort-header.html' with field="created_date" sort=sort text=text %}
|
<a href="{{ url }}">{% trans "Federated community" %}</a>
|
||||||
</th>
|
</li>
|
||||||
<th>
|
</ul>
|
||||||
{% trans "Last Active" as text %}
|
</div>
|
||||||
{% include 'snippets/table-sort-header.html' with field="last_active_date" sort=sort text=text %}
|
</div>
|
||||||
</th>
|
|
||||||
<th>
|
<div class="table-container block">
|
||||||
{% trans "Status" as text %}
|
<table class="table is-striped">
|
||||||
{% include 'snippets/table-sort-header.html' with field="is_active" sort=sort text=text %}
|
<tr>
|
||||||
</th>
|
{% url 'settings-users' as url %}
|
||||||
<th>
|
<th>
|
||||||
{% trans "Remote instance" as text %}
|
{% trans "Username" 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="username" sort=sort text=text %}
|
||||||
</th>
|
</th>
|
||||||
</tr>
|
<th>
|
||||||
{% for user in users %}
|
{% trans "Date Added" as text %}
|
||||||
<tr>
|
{% include 'snippets/table-sort-header.html' with field="created_date" sort=sort text=text %}
|
||||||
<td><a href="{% url 'settings-user' user.id %}">{{ user.username }}</a></td>
|
</th>
|
||||||
<td>{{ user.created_date }}</td>
|
<th>
|
||||||
<td>{{ user.last_active_date }}</td>
|
{% trans "Last Active" as text %}
|
||||||
<td>{% if user.is_active %}{% trans "Active" %}{% else %}{% trans "Inactive" %}{% endif %}</td>
|
{% include 'snippets/table-sort-header.html' with field="last_active_date" sort=sort text=text %}
|
||||||
<td>
|
</th>
|
||||||
{% if user.federated_server %}
|
<th>
|
||||||
<a href="{% url 'settings-federated-server' user.federated_server.id %}">{{ user.federated_server.server_name }}</a>
|
{% trans "Status" as text %}
|
||||||
{% elif not user.local %}
|
{% include 'snippets/table-sort-header.html' with field="is_active" sort=sort text=text %}
|
||||||
<em>{% trans "Not set" %}</em>
|
</th>
|
||||||
|
{% if status != "local" %}
|
||||||
|
<th>
|
||||||
|
{% trans "Remote instance" as text %}
|
||||||
|
{% include 'snippets/table-sort-header.html' with field="federated_server__server_name" sort=sort text=text %}
|
||||||
|
</th>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</td>
|
</tr>
|
||||||
</tr>
|
{% for user in users %}
|
||||||
{% endfor %}
|
<tr>
|
||||||
</table>
|
<td><a href="{% url 'settings-user' user.id %}">{{ user|username }}</a></td>
|
||||||
|
<td>{{ user.created_date }}</td>
|
||||||
|
<td>{{ user.last_active_date }}</td>
|
||||||
|
<td>{% if user.is_active %}{% trans "Active" %}{% else %}{% trans "Inactive" %}{% endif %}</td>
|
||||||
|
{% if status != "local" %}
|
||||||
|
<td>
|
||||||
|
{% if user.federated_server %}
|
||||||
|
<a href="{% url 'settings-federated-server' user.federated_server.id %}">{{ user.federated_server.server_name }}</a>
|
||||||
|
{% else %}
|
||||||
|
<em>{% trans "Not set" %}</em>
|
||||||
|
{% endif %}
|
||||||
|
</td>
|
||||||
|
{% endif %}
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
{% include 'snippets/pagination.html' with page=users path=request.path %}
|
{% include 'snippets/pagination.html' with page=users path=request.path %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -125,6 +125,11 @@ urlpatterns = [
|
||||||
re_path(
|
re_path(
|
||||||
r"^settings/users/?$", views.UserAdminList.as_view(), name="settings-users"
|
r"^settings/users/?$", views.UserAdminList.as_view(), name="settings-users"
|
||||||
),
|
),
|
||||||
|
re_path(
|
||||||
|
r"^settings/users/(?P<status>(local|federated))\/?$",
|
||||||
|
views.UserAdminList.as_view(),
|
||||||
|
name="settings-users",
|
||||||
|
),
|
||||||
re_path(
|
re_path(
|
||||||
r"^settings/users/(?P<user>\d+)/?$",
|
r"^settings/users/(?P<user>\d+)/?$",
|
||||||
views.UserAdmin.as_view(),
|
views.UserAdmin.as_view(),
|
||||||
|
|
|
@ -19,7 +19,7 @@ from bookwyrm.settings import PAGE_LENGTH
|
||||||
class UserAdminList(View):
|
class UserAdminList(View):
|
||||||
"""admin view of users on this server"""
|
"""admin view of users on this server"""
|
||||||
|
|
||||||
def get(self, request):
|
def get(self, request, status="local"):
|
||||||
"""list of users"""
|
"""list of users"""
|
||||||
filters = {}
|
filters = {}
|
||||||
server = request.GET.get("server")
|
server = request.GET.get("server")
|
||||||
|
@ -37,6 +37,8 @@ class UserAdminList(View):
|
||||||
if email:
|
if email:
|
||||||
filters["email__endswith"] = email
|
filters["email__endswith"] = email
|
||||||
|
|
||||||
|
filters["local"] = status == "local"
|
||||||
|
|
||||||
users = models.User.objects.filter(**filters)
|
users = models.User.objects.filter(**filters)
|
||||||
|
|
||||||
sort = request.GET.get("sort", "-created_date")
|
sort = request.GET.get("sort", "-created_date")
|
||||||
|
@ -56,6 +58,7 @@ class UserAdminList(View):
|
||||||
"users": paginated.get_page(request.GET.get("page")),
|
"users": paginated.get_page(request.GET.get("page")),
|
||||||
"sort": sort,
|
"sort": sort,
|
||||||
"server": server,
|
"server": server,
|
||||||
|
"status": status,
|
||||||
}
|
}
|
||||||
return TemplateResponse(request, "settings/users/user_admin.html", data)
|
return TemplateResponse(request, "settings/users/user_admin.html", data)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue