{% extends "base.html" %} {% block title %}Admin Users{% endblock %} {% block breadcrumb %}Admin Users{% endblock %} {% block content %} {# ── Stats ── #}
{{ users|length }}
Total Admins
{{ users|selectattr('is_superuser')|list|length }}
Superadmins
{{ users|rejectattr('is_superuser')|selectattr('is_staff')|list|length }}
Staff
{{ users|selectattr('is_active')|list|length }}
Active
{# ── Hierarchy Legend ── #}
Role Hierarchy
Superadmin — Full system access, user management, all permissions
Staff — Full CRUD, audit log, exports, bulk actions
Viewer — Read-only dashboard access
{# ── Users Table ── #}
{% for user in users %} {% else %} {% endfor %}
User Email Role Status Last Login Joined Actions
{% if user.avatar_path %} {{ user.username }} {% else %}
{{ (user.first_name or user.username)|truncate(1, True, '')|upper }}
{% endif %}
{{ user.username }}
{% if user.first_name or user.last_name %}
{{ user.first_name }} {{ user.last_name }}
{% endif %}
{{ user.email or '—' }} {% if user.is_superuser %} Superadmin {% elif user.is_staff %} Staff {% else %} Viewer {% endif %} {% if user.is_active %} Active {% else %} Inactive {% endif %} {{ user.last_login|default('Never')|string|truncate(19, True, '') }} {{ user.date_joined|default('')|string|truncate(10, True, '') }} {% if not user.is_superuser %} {% endif %}
No admin users found
{# ═══ Create User Modal ═══ #} {# ═══ Reset Password Modal ═══ #} {% endblock %} {% block extra_js %} function showResetPasswordModal(userId, username) { document.getElementById('resetPasswordUserId').value = userId; document.getElementById('resetPasswordUsername').textContent = username; document.getElementById('resetPasswordModal').style.display = 'flex'; } function toggleUserStatus(userId, isActive) { var action = isActive ? 'deactivate' : 'activate'; showConfirmModal( (isActive ? 'Deactivate' : 'Activate') + ' this admin?', 'The user will be ' + (isActive ? 'prevented from logging in' : 'able to log in again') + '.', function() { var form = document.createElement('form'); form.method = 'POST'; form.action = '{{ url_prefix|default("/admin") }}/admin-users/toggle-status'; var _t = document.querySelector('meta[name="csrf-token"]'); if (_t) { var c = document.createElement('input'); c.type='hidden'; c.name='_csrf_token'; c.value=_t.content; form.appendChild(c); } var input = document.createElement('input'); input.type = 'hidden'; input.name = 'user_id'; input.value = userId; form.appendChild(input); document.body.appendChild(form); form.submit(); } ); } function confirmDeleteUser(userId, username) { showConfirmModal( 'Delete admin "' + username + '"?', 'This action cannot be undone. The admin account will be permanently removed.', function() { var form = document.createElement('form'); form.method = 'POST'; form.action = '{{ url_prefix|default("/admin") }}/admin-users/delete'; var _t = document.querySelector('meta[name="csrf-token"]'); if (_t) { var c = document.createElement('input'); c.type='hidden'; c.name='_csrf_token'; c.value=_t.content; form.appendChild(c); } var input = document.createElement('input'); input.type = 'hidden'; input.name = 'user_id'; input.value = userId; form.appendChild(input); document.body.appendChild(form); form.submit(); }, true ); } {% endblock %}