diff --git a/.claude/settings.local.json b/.claude/settings.local.json index dd0d9ef..4a9bca7 100644 --- a/.claude/settings.local.json +++ b/.claude/settings.local.json @@ -10,7 +10,10 @@ "Bash(python -c \"from maxapi.types import SendedMessage; print\\(SendedMessage.__fields__ if hasattr\\(SendedMessage, ''__fields__''\\) else dir\\(SendedMessage\\)\\)\")", "Bash(python -c \"from maxapi.context import State; s = State\\(\\); print\\(type\\(s\\), dir\\(s\\)\\)\")", "Bash(python -c \"import maxapi; print\\(maxapi.__file__\\)\")", - "Bash(find C:UsersProfessionalAppDataLocalProgramsPythonPython313Libsite-packagesmaxapi -name command.py -o -name *command*)" + "Bash(find C:UsersProfessionalAppDataLocalProgramsPythonPython313Libsite-packagesmaxapi -name command.py -o -name *command*)", + "Bash(python -m py_compile bot/texts.py bot/flow_config.py bot/keyboards.py bot/handlers/start.py bot/handlers/create_ticket.py bot/handlers/view_tickets.py bot/handlers/menu.py)", + "Bash(pip show:*)", + "Bash(python -c \"import ast, pathlib; errors = [f''{p}: {e}'' for p in pathlib.Path\\(''bot''\\).rglob\\(''*.py''\\) for e in [None] if not \\(lambda: ast.parse\\(p.read_text\\(encoding=''utf-8''\\)\\)\\)\\(\\)]; print\\(''OK''\\)\")" ] } } diff --git a/admin/routes/bot_users.py b/admin/routes/bot_users.py index 3274ef5..91e928e 100644 --- a/admin/routes/bot_users.py +++ b/admin/routes/bot_users.py @@ -4,6 +4,7 @@ from fastapi.responses import HTMLResponse, RedirectResponse from admin.auth import require_admin from admin.templates_env import templates from database.queries.bot_users import ( + change_org_bot_user, delete_bot_user, get_all_bot_users, reset_bot_user, @@ -46,6 +47,12 @@ async def unblock_user(user_id: int, org_id: int = Form(...)): return RedirectResponse("/admin/bot-users", status_code=303) +@router.post("/{user_id}/change-org") +async def change_org(user_id: int, org_id: int = Form(...)): + await change_org_bot_user(user_id=user_id, org_id=org_id) + return RedirectResponse("/admin/bot-users", status_code=303) + + @router.post("/{user_id}/reset") async def reset_user(user_id: int): """Сбрасывает авторизацию — пользователь должен заново авторизоваться через бот.""" diff --git a/admin/templates/bot_users/list.html b/admin/templates/bot_users/list.html index 74189be..2467b7f 100644 --- a/admin/templates/bot_users/list.html +++ b/admin/templates/bot_users/list.html @@ -65,6 +65,19 @@ {% endif %} + {# Сменить организацию — только для авторизованных и незаблокированных #} + {% if u.is_authorized and not u.is_blocked %} +
+ {% endif %} + {# Сбросить авторизацию — для авторизованных и заблокированных (повторная auth через бот) #} {% if u.is_authorized or u.is_blocked %}