Add page-local ticket adjust route that returns HX-Refresh
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 50s
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:
@@ -3,8 +3,9 @@ Page summary blueprint — shows upcoming events across all calendars
|
|||||||
for a container (e.g. the village hall).
|
for a container (e.g. the village hall).
|
||||||
|
|
||||||
Routes:
|
Routes:
|
||||||
GET /<slug>/ — full page with first page of entries
|
GET /<slug>/ — full page with first page of entries
|
||||||
GET /<slug>/entries — HTMX fragment for infinite scroll
|
GET /<slug>/entries — HTMX fragment for infinite scroll
|
||||||
|
POST /<slug>/tickets/adjust — adjust ticket quantity, returns HX-Refresh
|
||||||
"""
|
"""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
@@ -78,4 +79,25 @@ def register() -> Blueprint:
|
|||||||
)
|
)
|
||||||
return await make_response(html, 200)
|
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
|
return bp
|
||||||
|
|||||||
@@ -30,7 +30,7 @@
|
|||||||
{% if entry.ticket_price is not none %}
|
{% if entry.ticket_price is not none %}
|
||||||
<div class="shrink-0">
|
<div class="shrink-0">
|
||||||
{% set qty = pending_tickets.get(entry.id, 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">
|
<div class="flex items-center gap-2 text-sm">
|
||||||
<span class="text-green-600 font-medium">£{{ '%.2f'|format(entry.ticket_price) }}</span>
|
<span class="text-green-600 font-medium">£{{ '%.2f'|format(entry.ticket_price) }}</span>
|
||||||
|
|
||||||
|
|||||||
@@ -32,7 +32,7 @@
|
|||||||
<span class="text-xs text-green-600 font-medium">£{{ '%.2f'|format(entry.ticket_price) }}/ticket</span>
|
<span class="text-xs text-green-600 font-medium">£{{ '%.2f'|format(entry.ticket_price) }}/ticket</span>
|
||||||
|
|
||||||
{% set qty = pending_tickets.get(entry.id, 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') %}
|
||||||
|
|
||||||
{% if qty == 0 %}
|
{% if qty == 0 %}
|
||||||
<form
|
<form
|
||||||
|
|||||||
Reference in New Issue
Block a user