All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 3m41s
Replace Python GET page handlers with declarative defpage definitions in .sx files across all 8 apps (sx docs, orders, account, market, cart, federation, events, blog). Each app now has sxc/pages/ with setup functions, layout registrations, page helpers, and .sx defpage declarations. Core infrastructure: add g I/O primitive, PageDef support for auth/layout/ data/content/filter/aside/menu slots, post_author auth level, and custom layout registration. Remove ~1400 lines of render_*_page/render_*_oob boilerplate. Update all endpoint references in routes, sx_components, and templates to defpage_* naming. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
62 lines
1.9 KiB
Python
62 lines
1.9 KiB
Python
from __future__ import annotations
|
|
|
|
from quart import (
|
|
request, Blueprint, g
|
|
)
|
|
|
|
|
|
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.before_request
|
|
async def _prepare_page_data():
|
|
if "defpage_" not in (request.endpoint or ""):
|
|
return
|
|
from shared.sx.page import get_template_context
|
|
from sx.sx_components import _calendar_admin_main_panel_html
|
|
ctx = await get_template_context()
|
|
g.calendar_admin_content = _calendar_admin_main_panel_html(ctx)
|
|
|
|
from shared.sx.pages import mount_pages
|
|
mount_pages(bp, "events", names=["calendar-admin"])
|
|
|
|
@bp.get("/description/")
|
|
@require_admin
|
|
async def calendar_description_edit(calendar_slug: str, **kwargs):
|
|
from sx.sx_components import render_calendar_description_edit
|
|
html = 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 sx.sx_components import render_calendar_description
|
|
html = 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 sx.sx_components import render_calendar_description
|
|
html = render_calendar_description(g.calendar)
|
|
return sx_response(html)
|
|
|
|
return bp
|