Add page-local ticket adjust route that returns HX-Refresh
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 50s

The cards were posting to tickets.adjust_quantity which returns the
entry detail buy form — wrong context for the page summary. New
page_summary.adjust_ticket route calls the service and returns
HX-Refresh: true so the whole listing refreshes with correct counts.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
giles
2026-02-22 22:56:42 +00:00
parent f1b3093d94
commit b8724eaf66
3 changed files with 26 additions and 4 deletions

View File

@@ -3,8 +3,9 @@ Page summary blueprint — shows upcoming events across all calendars
for a container (e.g. the village hall).
Routes:
GET /<slug>/ — full page with first page of entries
GET /<slug>/entries — HTMX fragment for infinite scroll
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
"""
from __future__ import annotations
@@ -78,4 +79,25 @@ def register() -> Blueprint:
)
return await make_response(html, 200)
@bp.post("/tickets/adjust")
async def adjust_ticket():
"""Adjust ticket quantity and refresh the page."""
ident = current_cart_identity()
form = await request.form
entry_id = int(form.get("entry_id", 0))
count = max(int(form.get("count", 0)), 0)
tt_raw = (form.get("ticket_type_id") or "").strip()
ticket_type_id = int(tt_raw) if tt_raw else None
await services.calendar.adjust_ticket_quantity(
g.s, entry_id, count,
user_id=ident["user_id"],
session_id=ident["session_id"],
ticket_type_id=ticket_type_id,
)
resp = await make_response("", 200)
resp.headers["HX-Refresh"] = "true"
return resp
return bp

View File

@@ -30,7 +30,7 @@
{% if entry.ticket_price is not none %}
<div class="shrink-0">
{% set qty = pending_tickets.get(entry.id, 0) %}
{% set ticket_url = url_for('tickets.adjust_quantity') %}
{% set ticket_url = url_for('page_summary.adjust_ticket') %}
<div class="flex items-center gap-2 text-sm">
<span class="text-green-600 font-medium">&pound;{{ '%.2f'|format(entry.ticket_price) }}</span>

View File

@@ -32,7 +32,7 @@
<span class="text-xs text-green-600 font-medium">&pound;{{ '%.2f'|format(entry.ticket_price) }}/ticket</span>
{% set qty = pending_tickets.get(entry.id, 0) %}
{% set ticket_url = url_for('tickets.adjust_quantity') %}
{% set ticket_url = url_for('page_summary.adjust_ticket') %}
{% if qty == 0 %}
<form