Merge pull request #2015 from bookwyrm-social/admin-view-fix

Improves user admin view
This commit is contained in:
Mouse Reeve 2022-03-14 09:50:31 -07:00 committed by GitHub
commit e0c0bebf65
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 119 additions and 47 deletions

View file

@ -0,0 +1,7 @@
{% extends 'snippets/filters_panel/filters_panel.html' %}
{% block filter_fields %}
{% include 'settings/users/username_filter.html' %}
{% include 'directory/community_filter.html' %}
{% include 'settings/users/server_filter.html' %}
{% endblock %}

View file

@ -30,7 +30,7 @@
</ul> </ul>
</div> </div>
{% include 'settings/users/user_admin_filters.html' %} {% include 'settings/reports/report_filters.html' %}
<div class="block"> <div class="block">
{% if not reports %} {% if not reports %}

View file

@ -0,0 +1,16 @@
{% extends 'snippets/filters_panel/filter_field.html' %}
{% load i18n %}
{% block filter %}
<label class="label" for="id_email">{% trans "Email" %}</label>
<div class="control">
<input
type="text"
class="input"
name="email"
value="{{ request.GET.email|default:'' }}"
id="id_email" placeholder="user@email.com"
>
</div>
{% endblock %}

View file

@ -1,10 +1,23 @@
{% extends 'settings/layout.html' %} {% extends 'settings/layout.html' %}
{% load i18n %} {% load i18n %}
{% load utilities %}
{% block title %}{{ user.username }}{% endblock %} {% block title %}{{ user.username }}{% endblock %}
{% block header %} {% block header %}
{{ user.username }} {{ user.username }}
<a class="help has-text-weight-normal" href="{% url 'settings-users' %}">{% trans "Back to users" %}</a> {% endblock %}
{% block breadcrumbs %}
<nav class="breadcrumb subtitle" aria-label="breadcrumbs">
<ul>
<li><a href="{% url 'settings-users' %}">{% trans "Users" %}</a></li>
<li class="is-active">
<a href="#" aria-current="page">
{{ user|username }}
</a>
</li>
</ul>
</nav>
{% endblock %} {% endblock %}
{% block panel %} {% block panel %}

View file

@ -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,6 +17,22 @@
{% include 'settings/users/user_admin_filters.html' %} {% include 'settings/users/user_admin_filters.html' %}
<div class="block">
<div class="tabs">
<ul>
{% url 'settings-users' as url %}
<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="federated" as url %}
<li {% if url in request.path %}class="is-active" aria-current="page"{% endif %}>
<a href="{{ url }}">{% trans "Federated community" %}</a>
</li>
</ul>
</div>
</div>
<div class="table-container block">
<table class="table is-striped"> <table class="table is-striped">
<tr> <tr>
{% url 'settings-users' as url %} {% url 'settings-users' as url %}
@ -34,27 +52,32 @@
{% 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" %}
<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 %}
</th> </th>
{% endif %}
</tr> </tr>
{% for user in users %} {% for user in users %}
<tr> <tr>
<td><a href="{% url 'settings-user' user.id %}">{{ user.username }}</a></td> <td><a href="{% url 'settings-user' user.id %}">{{ user|username }}</a></td>
<td>{{ user.created_date }}</td> <td>{{ user.created_date }}</td>
<td>{{ user.last_active_date }}</td> <td>{{ user.last_active_date }}</td>
<td>{% if user.is_active %}{% trans "Active" %}{% else %}{% trans "Inactive" %}{% endif %}</td> <td>{% if user.is_active %}{% trans "Active" %}{% else %}{% trans "Inactive" %}{% endif %}</td>
{% if status != "local" %}
<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>
{% elif not user.local %} {% else %}
<em>{% trans "Not set" %}</em> <em>{% trans "Not set" %}</em>
{% endif %} {% endif %}
</td> </td>
{% endif %}
</tr> </tr>
{% endfor %} {% endfor %}
</table> </table>
</div>
{% include 'snippets/pagination.html' with page=users path=request.path %} {% include 'snippets/pagination.html' with page=users path=request.path %}
{% endblock %} {% endblock %}

View file

@ -2,6 +2,11 @@
{% block filter_fields %} {% block filter_fields %}
{% include 'settings/users/username_filter.html' %} {% include 'settings/users/username_filter.html' %}
{% include 'directory/community_filter.html' %}
{% if status != "local" %}
{% include 'settings/users/server_filter.html' %} {% include 'settings/users/server_filter.html' %}
{% else %}
{% include 'settings/users/email_filter.html' %}
{% endif %}
{% endblock %} {% endblock %}

View file

@ -71,14 +71,14 @@
<dd>{{ user.last_active_date }}</dd> <dd>{{ user.last_active_date }}</dd>
<dt class="is-pulled-left mr-5">{% trans "Manually approved followers:" %}</dt> <dt class="is-pulled-left mr-5">{% trans "Manually approved followers:" %}</dt>
<dd>{{ user.manually_approves_followers }}</dd> <dd>{{ user.manually_approves_followers|yesno }}</dd>
<dt class="is-pulled-left mr-5">{% trans "Discoverable:" %}</dt> <dt class="is-pulled-left mr-5">{% trans "Discoverable:" %}</dt>
<dd>{{ user.discoverable }}</dd> <dd>{{ user.discoverable|yesno }}</dd>
{% if not user.is_active %} {% if not user.is_active %}
<dt class="is-pulled-left mr-5">{% trans "Deactivation reason:" %}</dt> <dt class="is-pulled-left mr-5">{% trans "Deactivation reason:" %}</dt>
<dd>{{ user.deactivation_reason }}</dd> <dd>{{ user.get_deactivation_reason_display }}</dd>
{% endif %} {% endif %}
{% if not user.is_active and user.deactivation_reason == "pending" %} {% if not user.is_active and user.deactivation_reason == "pending" %}
@ -104,7 +104,7 @@
<dd>{{ server.application_version }}</dd> <dd>{{ server.application_version }}</dd>
<dt class="is-pulled-left mr-5">{% trans "Status:" %}</dt> <dt class="is-pulled-left mr-5">{% trans "Status:" %}</dt>
<dd>{{ server.status }}</dd> <dd>{{ server.get_status_display }}</dd>
</dl> </dl>
{% if server.notes %} {% if server.notes %}
<h5>{% trans "Notes" %}</h5> <h5>{% trans "Notes" %}</h5>

View file

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

View file

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