republisher/repub/web/admin/pages/runs.py

27 lines
873 B
Python
Raw Normal View History

2026-06-02 10:18:59 +02:00
from __future__ import annotations
from collections.abc import Awaitable, Callable
from typing import Any
from datastar_py.quart import DatastarResponse
from quart import Quart, Response
from repub.web.app import _page_patch_response, _shim_page_response, render_runs
RouteGuard = Callable[[Callable[..., Awaitable[Any]]], Callable[..., Awaitable[Any]]]
def register_runs_routes(app: Quart, *, admin_required: RouteGuard) -> None:
@app.get("/admin/runs")
@admin_required
async def admin_runs_home() -> Response:
return _shim_page_response(current_path="/admin/runs", static_prefix="/admin")
@app.post("/admin/runs")
@admin_required
async def admin_runs_patch() -> DatastarResponse:
return await _page_patch_response(
app,
lambda tab_id: render_runs(app, tab_id=tab_id, path_prefix="/admin"),
)