Add global all-events view at / and scope page summary to single page
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 53s
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 53s
Root / shows all upcoming events across all pages with page badges. /<slug>/ reverted to show only that page's events. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,9 +1,8 @@
|
||||
"""
|
||||
Page summary blueprint — shows upcoming events across all calendars
|
||||
for all pages.
|
||||
Page summary blueprint — shows upcoming events for a single page's calendars.
|
||||
|
||||
Routes:
|
||||
GET /<slug>/ — full page with first page of entries
|
||||
GET /<slug>/ — full page scoped to this page
|
||||
GET /<slug>/entries — HTMX fragment for infinite scroll
|
||||
POST /<slug>/tickets/adjust — adjust ticket quantity inline
|
||||
"""
|
||||
@@ -19,10 +18,10 @@ from shared.services.registry import services
|
||||
def register() -> Blueprint:
|
||||
bp = Blueprint("page_summary", __name__)
|
||||
|
||||
async def _load_entries(page, per_page=20):
|
||||
"""Load all upcoming entries + pending ticket counts + page titles."""
|
||||
async def _load_entries(post_id, page, per_page=20):
|
||||
"""Load upcoming entries for this page + pending ticket counts."""
|
||||
entries, has_more = await services.calendar.upcoming_entries_for_container(
|
||||
g.s, page=page, per_page=per_page,
|
||||
g.s, "page", post_id, page=page, per_page=per_page,
|
||||
)
|
||||
|
||||
# Pending ticket counts keyed by entry_id
|
||||
@@ -36,33 +35,21 @@ def register() -> Blueprint:
|
||||
if t.entry_id is not None:
|
||||
pending_tickets[t.entry_id] = pending_tickets.get(t.entry_id, 0) + 1
|
||||
|
||||
# Batch-load page info for container_ids
|
||||
page_info = {} # {post_id: {title, slug}}
|
||||
if entries:
|
||||
post_ids = list({
|
||||
e.calendar_container_id
|
||||
for e in entries
|
||||
if e.calendar_container_type == "page" and e.calendar_container_id
|
||||
})
|
||||
if post_ids:
|
||||
posts = await services.blog.get_posts_by_ids(g.s, post_ids)
|
||||
for p in posts:
|
||||
page_info[p.id] = {"title": p.title, "slug": p.slug}
|
||||
|
||||
return entries, has_more, pending_tickets, page_info
|
||||
return entries, has_more, pending_tickets
|
||||
|
||||
@bp.get("/")
|
||||
async def index():
|
||||
post = g.post_data["post"]
|
||||
view = request.args.get("view", "list")
|
||||
page = int(request.args.get("page", 1))
|
||||
|
||||
entries, has_more, pending_tickets, page_info = await _load_entries(page)
|
||||
entries, has_more, pending_tickets = await _load_entries(post["id"], page)
|
||||
|
||||
ctx = dict(
|
||||
entries=entries,
|
||||
has_more=has_more,
|
||||
pending_tickets=pending_tickets,
|
||||
page_info=page_info,
|
||||
page_info={},
|
||||
page=page,
|
||||
view=view,
|
||||
)
|
||||
@@ -76,17 +63,18 @@ def register() -> Blueprint:
|
||||
|
||||
@bp.get("/entries")
|
||||
async def entries_fragment():
|
||||
post = g.post_data["post"]
|
||||
view = request.args.get("view", "list")
|
||||
page = int(request.args.get("page", 1))
|
||||
|
||||
entries, has_more, pending_tickets, page_info = await _load_entries(page)
|
||||
entries, has_more, pending_tickets = await _load_entries(post["id"], page)
|
||||
|
||||
html = await render_template(
|
||||
"_types/page_summary/_cards.html",
|
||||
entries=entries,
|
||||
has_more=has_more,
|
||||
pending_tickets=pending_tickets,
|
||||
page_info=page_info,
|
||||
page_info={},
|
||||
page=page,
|
||||
view=view,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user