pewpewpew/templates/admin/users.html

56 lines
2 KiB
HTML

{% extends "base.html" %}
{% block content %}
<h2>Управление пользователями</h2>
{% with messages = get_flashed_messages(with_categories=true) %}
{% if messages %}
{% for category, message in messages %}
<div class="alert alert-{{ category }}">{{ message }}</div>
{% endfor %}
{% endif %}
{% endwith %}
<div class="admin-table">
<table>
<thead>
<tr>
<th>ID</th>
<th>Имя пользователя</th>
<th>Email</th>
<th>Роль</th>
<th>Дата регистрации</th>
<th>Действия</th>
</tr>
</thead>
<tbody>
{% for user in users %}
<tr>
<td>{{ user.id }}</td>
<td>{{ user.username }}</td>
<td>{{ user.email or '-' }}</td>
<td>
{% if user.role == 'admin' %}
<span class="badge badge-admin">Админ</span>
{% else %}
<span class="badge badge-user">Пользователь</span>
{% endif %}
</td>
<td>{{ user.created_at[:10] }}</td>
<td>
{% if user.role != 'admin' %}
<form method="POST" action="{{ url_for('make_admin', user_id=user.id) }}" style="display: inline;">
<button type="submit" class="btn btn-warning btn-sm">Сделать админом</button>
</form>
{% endif %}
<form method="POST" action="{{ url_for('delete_user', user_id=user.id) }}" style="display: inline;" onsubmit="return confirm('Удалить пользователя?')">
<button type="submit" class="btn btn-danger btn-sm">Удалить</button>
</form>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% endblock %}