Widget Phase 2: events app consumes container_nav widgets
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 54s
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 54s
Day view and entry detail now load and render registered container_nav widgets (e.g. market links) from the same container page — matching how blog post pages work. Calendar-domain widgets are skipped since we're already on a calendar page. Adds /w/<widget_domain>/ paginate route for infinite scroll support. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -27,6 +27,8 @@ from datetime import datetime, timezone
|
||||
import math
|
||||
import logging
|
||||
|
||||
from shared.services.widget_registry import widgets
|
||||
|
||||
from ..ticket_types.routes import register as register_ticket_types
|
||||
|
||||
from .admin.routes import register as register_admin
|
||||
@@ -220,6 +222,26 @@ def register():
|
||||
ticket_type_id=tt.id,
|
||||
)
|
||||
|
||||
# Widget-driven container nav (market links, etc.)
|
||||
container_nav_loaded = []
|
||||
post_data = getattr(g, "post_data", None)
|
||||
if post_data:
|
||||
post_id = post_data["post"]["id"]
|
||||
post_slug = post_data["post"]["slug"]
|
||||
for w in widgets.container_nav:
|
||||
if w.domain.startswith("calendar"):
|
||||
continue # skip — we're already on a calendar page
|
||||
try:
|
||||
wctx = await w.context_fn(
|
||||
g.s, container_type="page", container_id=post_id,
|
||||
post_slug=post_slug,
|
||||
)
|
||||
has_data = any(v for v in wctx.values() if isinstance(v, list) and v)
|
||||
if has_data:
|
||||
container_nav_loaded.append({"widget": w, "ctx": wctx})
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
return {
|
||||
"entry": calendar_entry,
|
||||
"entry_posts": entry_posts,
|
||||
@@ -227,7 +249,8 @@ def register():
|
||||
"ticket_sold_count": ticket_sold_count,
|
||||
"user_ticket_count": user_ticket_count,
|
||||
"user_ticket_counts_by_type": user_ticket_counts_by_type,
|
||||
}
|
||||
"container_nav_widgets": container_nav_loaded,
|
||||
}
|
||||
@bp.get("/")
|
||||
@require_admin
|
||||
async def get(entry_id: int, **rest):
|
||||
|
||||
@@ -11,6 +11,7 @@ from bp.calendar_entries.routes import register as register_calendar_entries
|
||||
from .admin.routes import register as register_admin
|
||||
|
||||
from shared.browser.app.redis_cacher import cache_page
|
||||
from shared.services.widget_registry import widgets
|
||||
|
||||
from models.calendars import CalendarSlot # add this import
|
||||
|
||||
@@ -77,6 +78,26 @@ def register():
|
||||
result = await g.s.execute(stmt)
|
||||
day_slots = list(result.scalars())
|
||||
|
||||
# Widget-driven container nav (market links, etc.)
|
||||
container_nav_loaded = []
|
||||
post_data = getattr(g, "post_data", None)
|
||||
if post_data:
|
||||
post_id = post_data["post"]["id"]
|
||||
post_slug = post_data["post"]["slug"]
|
||||
for w in widgets.container_nav:
|
||||
if w.domain.startswith("calendar"):
|
||||
continue # skip — we're already on a calendar page
|
||||
try:
|
||||
wctx = await w.context_fn(
|
||||
g.s, container_type="page", container_id=post_id,
|
||||
post_slug=post_slug,
|
||||
)
|
||||
has_data = any(v for v in wctx.values() if isinstance(v, list) and v)
|
||||
if has_data:
|
||||
container_nav_loaded.append({"widget": w, "ctx": wctx})
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
return {
|
||||
"qsession": qsession,
|
||||
"day_date": day_date,
|
||||
@@ -86,7 +107,8 @@ def register():
|
||||
"day_entries": visible.merged_entries,
|
||||
"user_entries": visible.user_entries,
|
||||
"confirmed_entries": visible.confirmed_entries,
|
||||
"day_slots": day_slots, # <-- NEW
|
||||
"day_slots": day_slots,
|
||||
"container_nav_widgets": container_nav_loaded,
|
||||
}
|
||||
|
||||
|
||||
@@ -118,5 +140,25 @@ def register():
|
||||
)
|
||||
return await make_response(html)
|
||||
|
||||
|
||||
@bp.get("/w/<widget_domain>/")
|
||||
async def widget_paginate(widget_domain: str, **kwargs):
|
||||
"""Generic paginated widget endpoint for infinite scroll."""
|
||||
page = int(request.args.get("page", 1))
|
||||
post_data = getattr(g, "post_data", None)
|
||||
if not post_data:
|
||||
abort(404)
|
||||
post_id = post_data["post"]["id"]
|
||||
post_slug = post_data["post"]["slug"]
|
||||
for w in widgets.container_nav:
|
||||
if w.domain == widget_domain:
|
||||
ctx = await w.context_fn(
|
||||
g.s, container_type="page", container_id=post_id,
|
||||
post_slug=post_slug, page=page,
|
||||
)
|
||||
html = await render_template(
|
||||
w.template, ctx=ctx, post=post_data["post"],
|
||||
)
|
||||
return await make_response(html)
|
||||
abort(404)
|
||||
|
||||
return bp
|
||||
|
||||
2
shared
2
shared
Submodule shared updated: eec750a699...d0b1edea7a
Reference in New Issue
Block a user