Replace widget registry with fragment fetches (Phase 5)
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 42s
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 42s
Account nav and page panels now fetched from events/cart fragments instead of using shared widget registry. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
"""Account pages blueprint.
|
||||
|
||||
Moved from federation/bp/auth — newsletters, widget pages (tickets, bookings).
|
||||
Moved from federation/bp/auth — newsletters, fragment pages (tickets, bookings).
|
||||
Mounted at root /.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
@@ -17,8 +17,8 @@ from sqlalchemy import select
|
||||
|
||||
from shared.models import UserNewsletter
|
||||
from shared.models.ghost_membership_entities import GhostNewsletter
|
||||
from shared.services.widget_registry import widgets
|
||||
from shared.infrastructure.urls import login_url
|
||||
from shared.infrastructure.fragments import fetch_fragment, fetch_fragments
|
||||
|
||||
oob = {
|
||||
"oob_extends": "oob_elements.html",
|
||||
@@ -36,8 +36,12 @@ def register(url_prefix="/"):
|
||||
account_bp = Blueprint("account", __name__, url_prefix=url_prefix)
|
||||
|
||||
@account_bp.context_processor
|
||||
def context():
|
||||
return {"oob": oob, "account_nav_links": widgets.account_nav}
|
||||
async def context():
|
||||
events_nav, cart_nav = await fetch_fragments([
|
||||
("events", "account-nav-item", {}),
|
||||
("cart", "account-nav-item", {}),
|
||||
])
|
||||
return {"oob": oob, "account_nav_html": events_nav + cart_nav}
|
||||
|
||||
@account_bp.get("/")
|
||||
async def account():
|
||||
@@ -128,33 +132,35 @@ def register(url_prefix="/"):
|
||||
un=un,
|
||||
)
|
||||
|
||||
# Catch-all for widget pages — must be last
|
||||
# Catch-all for fragment-provided pages — must be last
|
||||
@account_bp.get("/<slug>/")
|
||||
async def widget_page(slug):
|
||||
async def fragment_page(slug):
|
||||
from shared.browser.app.utils.htmx import is_htmx_request
|
||||
from quart import abort
|
||||
|
||||
widget = widgets.account_page_by_slug(slug)
|
||||
if not widget:
|
||||
abort(404)
|
||||
|
||||
if not g.get("user"):
|
||||
return redirect(login_url(f"/{slug}/"))
|
||||
|
||||
ctx = await widget.context_fn(g.s, user_id=g.user.id)
|
||||
w_oob = {**oob, "main": widget.template}
|
||||
fragment_html = await fetch_fragment(
|
||||
"events", "account-page",
|
||||
params={"slug": slug, "user_id": str(g.user.id)},
|
||||
)
|
||||
if not fragment_html:
|
||||
abort(404)
|
||||
|
||||
w_oob = {**oob, "main": "_types/auth/_fragment_panel.html"}
|
||||
|
||||
if not is_htmx_request():
|
||||
html = await render_template(
|
||||
"_types/auth/index.html",
|
||||
oob=w_oob,
|
||||
**ctx,
|
||||
page_fragment_html=fragment_html,
|
||||
)
|
||||
else:
|
||||
html = await render_template(
|
||||
"_types/auth/_oob_elements.html",
|
||||
oob=w_oob,
|
||||
**ctx,
|
||||
page_fragment_html=fragment_html,
|
||||
)
|
||||
|
||||
return await make_response(html)
|
||||
|
||||
2
shared
2
shared
Submodule shared updated: d2e07e047e...65c4989d08
Reference in New Issue
Block a user