Decouple blog UI via widget registry
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 54s

Replace explicit calendar/market service calls in post routes, auth
routes, and listing cards with widget-driven iteration. Zero cross-domain
imports remain in blog bp layer.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
giles
2026-02-19 18:04:26 +00:00
parent bb60835c58
commit 8af7c69090
3 changed files with 51 additions and 69 deletions

View File

@@ -27,6 +27,7 @@ from shared.models.ghost_membership_entities import GhostNewsletter
from shared.config import config
from shared.utils import host_url
from shared.infrastructure.urls import coop_url
from shared.services.widget_registry import widgets
from sqlalchemy.orm import selectinload
from shared.browser.app.redis_cacher import clear_cache
@@ -68,6 +69,7 @@ def register(url_prefix="/auth"):
def context():
return {
"oob": oob,
"account_nav_links": widgets.account_nav,
}
# NOTE: load_current_user moved to shared/user_loader.py
@@ -150,56 +152,32 @@ def register(url_prefix="/auth"):
return await make_response(html)
@auth_bp.get("/tickets/")
async def tickets():
@auth_bp.get("/<slug>/")
async def widget_page(slug):
from shared.browser.app.utils.htmx import is_htmx_request
from shared.services.registry import services
widget = widgets.account_page_by_slug(slug)
if not widget:
from quart import abort
abort(404)
if not g.get("user"):
return redirect(host_url(url_for("auth.login_form")))
user_tickets = await services.calendar.user_tickets(g.s, user_id=g.user.id)
tk_oob = {**oob, "main": "_types/auth/_tickets_panel.html"}
ctx = await widget.context_fn(g.s, user_id=g.user.id)
w_oob = {**oob, "main": widget.template}
if not is_htmx_request():
html = await render_template(
"_types/auth/index.html",
oob=tk_oob,
tickets=user_tickets,
oob=w_oob,
**ctx,
)
else:
html = await render_template(
"_types/auth/_oob_elements.html",
oob=tk_oob,
tickets=user_tickets,
)
return await make_response(html)
@auth_bp.get("/bookings/")
async def bookings():
from shared.browser.app.utils.htmx import is_htmx_request
from shared.services.registry import services
if not g.get("user"):
return redirect(host_url(url_for("auth.login_form")))
user_bookings = await services.calendar.user_bookings(g.s, user_id=g.user.id)
bk_oob = {**oob, "main": "_types/auth/_bookings_panel.html"}
if not is_htmx_request():
html = await render_template(
"_types/auth/index.html",
oob=bk_oob,
bookings=user_bookings,
)
else:
html = await render_template(
"_types/auth/_oob_elements.html",
oob=bk_oob,
bookings=user_bookings,
oob=w_oob,
**ctx,
)
return await make_response(html)