Files
Quiz-for-Mont/templates/admin/users.html

85 lines
3.8 KiB
HTML
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{% extends "layout.html" %}
{% block content %}
<div class="container mt-4">
<div class="d-flex align-items-center mb-3">
<h3 class="me-auto">Пользователи</h3>
<a href="{{ url_for('manage_surveys') }}" class="btn btn-outline-secondary btn-sm">К опросам</a>
</div>
<div class="card mb-4">
<div class="card-body">
<h5 class="card-title">Создать пользователя</h5>
<form method="post" action="{{ url_for('manage_users') }}" class="row gy-2" onsubmit="showLoading(this)">
<div class="col-md-3">
<input type="text" name="username" class="form-control" placeholder="Логин" required>
</div>
<div class="col-md-3">
<input type="email" name="email" class="form-control" placeholder="Email" required>
</div>
<div class="col-md-3">
<input type="text" name="full_name" class="form-control" placeholder="ФИО (необязательно)">
</div>
<div class="col-md-2">
<input type="text" name="password" class="form-control" placeholder="Пароль" required>
</div>
<div class="col-md-1 d-flex align-items-center">
<div class="form-check">
<input class="form-check-input" type="checkbox" name="is_admin" id="is_admin">
<label class="form-check-label" for="is_admin">Админ</label>
</div>
</div>
<div class="col-12">
<button id="submitBtn" type="submit" class="btn btn-primary">Создать</button>
</div>
</form>
</div>
</div>
<div class="card">
<div class="card-body">
<h5 class="card-title">Список пользователей</h5>
<div class="table-responsive">
<table class="table align-middle">
<thead>
<tr>
<th>#</th>
<th>Логин</th>
<th>ФИО</th>
<th>Email</th>
<th>Роль</th>
<th style="width:320px">Действия</th>
</tr>
</thead>
<tbody>
{% for u in users %}
<tr>
<td>{{ u.id }}</td>
<td>{{ u.username }}</td>
<td>{{ u.full_name or '—' }}</td>
<td>{{ u.email }}</td>
<td>
{% if u.is_admin %}<span class="badge bg-danger">Админ</span>{% else %}<span class="badge bg-secondary">Пользователь</span>{% endif %}
</td>
<td>
<form method="post" action="{{ url_for('admin_reset_password', user_id=u.id) }}" class="d-inline-flex align-items-center gap-2" onsubmit="showLoading(this)">
<input type="text" name="new_password" class="form-control form-control-sm" placeholder="Новый пароль" required>
<button class="btn btn-sm btn-outline-primary" type="submit">Сменить пароль</button>
</form>
<form method="post" action="{{ url_for('admin_toggle_admin', user_id=u.id) }}" class="d-inline" onsubmit="return confirm('Изменить права пользователя?');">
<button class="btn btn-sm btn-outline-warning" type="submit">Переключить роль</button>
</form>
<form method="post" action="{{ url_for('admin_delete_user', user_id=u.id) }}" class="d-inline" onsubmit="return confirm('Удалить пользователя {{ u.username }}?');">
<button class="btn btn-sm btn-outline-danger" type="submit" {% if u.id == current_user.id %}disabled{% endif %}>Удалить</button>
</form>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
</div>
{% endblock %}