Phase 7 of the zero-Python-rendering plan. All 100 rendering functions move from events/sx/sx_components.py into events/sxc/pages/__init__.py. Route handlers (15 files) import from sxc.pages instead. load_service_components call moves into _load_events_page_files. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
50 lines
1.4 KiB
Python
50 lines
1.4 KiB
Python
from __future__ import annotations
|
|
|
|
from quart import (
|
|
Blueprint, g, request,
|
|
)
|
|
|
|
|
|
from shared.browser.app.authz import require_admin
|
|
from shared.browser.app.redis_cacher import clear_cache
|
|
from shared.sx.helpers import sx_response
|
|
|
|
|
|
|
|
|
|
def register():
|
|
bp = Blueprint("admin", __name__, url_prefix='/admin')
|
|
|
|
@bp.get("/description/")
|
|
@require_admin
|
|
async def calendar_description_edit(calendar_slug: str, **kwargs):
|
|
from sxc.pages import render_calendar_description_edit
|
|
html = await render_calendar_description_edit(g.calendar)
|
|
return sx_response(html)
|
|
|
|
|
|
@bp.post("/description/")
|
|
@require_admin
|
|
@clear_cache(tag="calendars", tag_scope="all")
|
|
async def calendar_description_save(calendar_slug: str, **kwargs):
|
|
form = await request.form
|
|
description = (form.get("description") or "").strip() or None
|
|
|
|
# simple inline update, or call a service if you prefer
|
|
g.calendar.description = description
|
|
await g.s.flush()
|
|
|
|
from sxc.pages import render_calendar_description
|
|
html = await render_calendar_description(g.calendar, oob=True)
|
|
return sx_response(html)
|
|
|
|
|
|
@bp.get("/description/view/")
|
|
@require_admin
|
|
async def calendar_description_view(calendar_slug: str, **kwargs):
|
|
from sxc.pages import render_calendar_description
|
|
html = await render_calendar_description(g.calendar)
|
|
return sx_response(html)
|
|
|
|
return bp
|