intra_max_chatbot/admin/templates/bot_users/list.html
2026-04-03 00:30:24 +03:00

109 lines
5.4 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 "base.html" %}
{% block title %}Пользователи бота{% endblock %}
{% block content %}
<h1>Пользователи бота</h1>
<div class="card">
<div class="filter-bar">
<form method="get" style="display:flex;gap:8px;flex-wrap:wrap">
<select name="is_authorized" onchange="this.form.submit()">
<option value="">Все статусы</option>
<option value="1" {% if filter_authorized == 1 %}selected{% endif %}>Авторизованные</option>
<option value="0" {% if filter_authorized == 0 %}selected{% endif %}>Не авторизованные</option>
</select>
<select name="is_blocked" onchange="this.form.submit()">
<option value="">Блокировка: все</option>
<option value="1" {% if filter_blocked == 1 %}selected{% endif %}>Заблокированные</option>
<option value="0" {% if filter_blocked == 0 %}selected{% endif %}>Не заблокированные</option>
</select>
<select name="org_id" onchange="this.form.submit()">
<option value="">Все организации</option>
{% for org in orgs %}
<option value="{{ org.id }}" {% if filter_org_id == org.id %}selected{% endif %}>{{ org.name }}</option>
{% endfor %}
</select>
</form>
</div>
<table>
<thead>
<tr>
<th>#</th><th>MAX ID</th><th>Имя</th><th>Телефон</th>
<th>Организация</th><th>Статус</th><th>Дата</th><th>Действия</th>
</tr>
</thead>
<tbody>
{% for u in users %}
<tr>
<td>{{ u.id }}</td>
<td>{{ u.max_user_id }}</td>
<td>{{ u.first_name or u.username or '—' }}</td>
<td>{{ u.phone or '—' }}</td>
<td>{{ u.org_name or '—' }}</td>
<td>
{% if u.is_blocked %}
<span class="badge badge-blocked">Заблокирован</span>
{% elif u.is_authorized %}
<span class="badge badge-auth">Авторизован</span>
{% else %}
<span class="badge badge-pending">Ожидает</span>
{% endif %}
</td>
<td>{{ u.created_at[:16] }}</td>
<td style="white-space:nowrap">
<div style="display:flex;flex-direction:column;gap:4px">
{# Разблокировать — только для заблокированных (admin задаёт org вручную) #}
{% if u.is_blocked %}
<form action="/admin/bot-users/{{ u.id }}/unblock" method="post"
style="display:flex;gap:4px;align-items:center">
<select name="org_id" required style="width:auto">
<option value="">орг</option>
{% for org in orgs %}
<option value="{{ org.id }}" {% if u.org_id == org.id %}selected{% endif %}>{{ org.name }}</option>
{% endfor %}
</select>
<button class="btn btn-primary" type="submit" title="Разблокировать и авторизовать">Разблокировать</button>
</form>
{% endif %}
{# Сменить организацию — только для авторизованных и незаблокированных #}
{% if u.is_authorized and not u.is_blocked %}
<form action="/admin/bot-users/{{ u.id }}/change-org" method="post"
style="display:flex;gap:4px;align-items:center">
<select name="org_id" required style="width:auto">
{% for org in orgs %}
<option value="{{ org.id }}" {% if u.org_id == org.id %}selected{% endif %}>{{ org.name }}</option>
{% endfor %}
</select>
<button class="btn btn-primary" type="submit">Сменить орг.</button>
</form>
{% endif %}
{# Сбросить авторизацию — для авторизованных и заблокированных (повторная auth через бот) #}
{% if u.is_authorized or u.is_blocked %}
<form action="/admin/bot-users/{{ u.id }}/reset" method="post">
<button class="btn btn-secondary" type="submit"
onclick="return confirm('Сбросить авторизацию? Пользователь должен будет заново поделиться контактом.')"
title="Сбросить — пользователь заново пройдёт авторизацию через бот">
Сбросить auth
</button>
</form>
{% endif %}
{# Удалить полностью #}
<form action="/admin/bot-users/{{ u.id }}/delete" method="post">
<button class="btn" style="background:#dc3545;color:#fff" type="submit"
onclick="return confirm('Удалить пользователя полностью? Это действие необратимо.')">
Удалить
</button>
</form>
</div>
</td>
</tr>
{% else %}
<tr><td colspan="8" style="text-align:center;color:#999">Нет пользователей</td></tr>
{% endfor %}
</tbody>
</table>
</div>
{% endblock %}