Add publisher dashboard routes
This commit is contained in:
parent
96551c2788
commit
e4a5246ab3
31 changed files with 1603 additions and 516 deletions
48
repub/web/admin/pages/sources.py
Normal file
48
repub/web/admin/pages/sources.py
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
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, request
|
||||
|
||||
from repub.web.app import (
|
||||
_page_patch_response,
|
||||
_shim_page_response,
|
||||
render_create_source,
|
||||
render_edit_source,
|
||||
render_sources,
|
||||
)
|
||||
|
||||
RouteGuard = Callable[[Callable[..., Awaitable[Any]]], Callable[..., Awaitable[Any]]]
|
||||
|
||||
|
||||
def register_source_routes(app: Quart, *, admin_required: RouteGuard) -> None:
|
||||
@app.get("/admin/sources")
|
||||
@app.get("/admin/sources/create")
|
||||
@app.get("/admin/sources/<string:slug>/edit")
|
||||
@admin_required
|
||||
async def admin_sources_shim(slug: str | None = None) -> Response:
|
||||
del slug
|
||||
return _shim_page_response(current_path=request.path, static_prefix="/admin")
|
||||
|
||||
@app.post("/admin/sources")
|
||||
@admin_required
|
||||
async def admin_sources_patch() -> DatastarResponse:
|
||||
return await _page_patch_response(app, lambda _tab_id: render_sources(app))
|
||||
|
||||
@app.post("/admin/sources/create")
|
||||
@admin_required
|
||||
async def admin_create_source_patch() -> DatastarResponse:
|
||||
return await _page_patch_response(
|
||||
app,
|
||||
lambda _tab_id: render_create_source(app),
|
||||
)
|
||||
|
||||
@app.post("/admin/sources/<string:slug>/edit")
|
||||
@admin_required
|
||||
async def admin_edit_source_patch(slug: str) -> DatastarResponse:
|
||||
return await _page_patch_response(
|
||||
app,
|
||||
lambda _tab_id: render_edit_source(slug, app),
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue