Show all events across all pages with page badges
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 1m1s

Page summary now loads all upcoming events globally, not just the
current page's. Each card shows an amber page badge when the event
belongs to a different page. Links use the correct page slug.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
giles
2026-02-22 23:05:11 +00:00
parent 39f500c41c
commit dad53fd1b5
5 changed files with 61 additions and 29 deletions

View File

@@ -1,11 +1,11 @@
"""
Page summary blueprint — shows upcoming events across all calendars
for a container (e.g. the village hall).
for all pages.
Routes:
GET /<slug>/ — full page with first page of entries
GET /<slug>/entries — HTMX fragment for infinite scroll
POST /<slug>/tickets/adjust — adjust ticket quantity, returns HX-Refresh
POST /<slug>/tickets/adjust — adjust ticket quantity inline
"""
from __future__ import annotations
@@ -19,10 +19,10 @@ from shared.services.registry import services
def register() -> Blueprint:
bp = Blueprint("page_summary", __name__)
async def _load_entries(post_id, page, per_page=20):
"""Load upcoming entries + pending ticket counts for current user."""
async def _load_entries(page, per_page=20):
"""Load all upcoming entries + pending ticket counts + page titles."""
entries, has_more = await services.calendar.upcoming_entries_for_container(
g.s, "page", post_id, page=page, per_page=per_page,
g.s, page=page, per_page=per_page,
)
# Pending ticket counts keyed by entry_id
@@ -36,20 +36,33 @@ def register() -> Blueprint:
if t.entry_id is not None:
pending_tickets[t.entry_id] = pending_tickets.get(t.entry_id, 0) + 1
return entries, has_more, pending_tickets
# 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
@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 = await _load_entries(post["id"], page)
entries, has_more, pending_tickets, page_info = await _load_entries(page)
ctx = dict(
entries=entries,
has_more=has_more,
pending_tickets=pending_tickets,
page_info=page_info,
page=page,
view=view,
)
@@ -63,17 +76,17 @@ 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 = await _load_entries(post["id"], page)
entries, has_more, pending_tickets, page_info = await _load_entries(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=page,
view=view,
)