DispelEvilBot/admin/routes/pages.py

61 lines
2.0 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": "Тексты бота и предпросмотр с тегами {tag}",
"url": "/messages",
},
{
"title": "Последовательности",
"description": "Приветствие и другие наборы сообщений по порядку",
"url": "/sequences",
},
{
"title": "Расписания",
"description": "Время рассылок, дни недели и шаблон",
"url": "/schedules",
},
{
"title": "Пользователи",
"description": "Ники, звания, баланс и подписка",
"url": "/users",
},
{
"title": "Админы",
"description": "Доступ к веб-панели",
"url": "/admins",
},
{
"title": "Логи",
"description": "События из ClickHouse с фильтрами",
"url": "/logs",
},
)
@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,
},
)