DispelEvilBot/admin/routes/pages.py

66 lines
2.1 KiB
Python
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.

"""HTML-страницы админки (серверный рендер Jinja2 + HTMX)."""
from __future__ import annotations
from fastapi import APIRouter, Request
from fastapi.responses import HTMLResponse
from common import __version__
router = APIRouter(tags=["pages"])
#: Разделы админки по плану Блока 4 (url — None, пока раздел не готов).
SECTIONS: tuple[dict[str, str | None], ...] = (
{
"title": "Шаблоны сообщений",
"description": "Тексты бота: сообщения, картинки и кнопки",
"url": "/sequences",
},
{
"title": "Расписания",
"description": "Время рассылок, дни недели и шаблон",
"url": "/schedules",
},
{
"title": "Пользователи",
"description": "Ники, звания, баланс и подписка",
"url": "/users",
},
{
"title": "Звания",
"description": "Справочник магазина званий",
"url": "/titles",
},
{
"title": "Админы",
"description": "Доступ к веб-панели",
"url": "/admins",
},
{
"title": "Логи",
"description": "События из ClickHouse с фильтрами",
"url": "/logs",
},
{
"title": "Отправить",
"description": "Сообщение в чат от имени бота",
"url": "/send",
},
)
@router.get("/", response_class=HTMLResponse)
async def index(request: Request) -> HTMLResponse:
"""Главная страница: версия, окружение и список будущих разделов."""
templates = request.app.state.templates
settings = request.app.state.settings
return templates.TemplateResponse(
request=request,
name="index.html",
context={
"version": __version__,
"app_env": settings.app_env,
"sections": SECTIONS,
},
)