Require a capacity on every ticket wave #64
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/per-wave-capacity"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Stacked on #63 — it depends on ticket waves existing, so it targets
rebase/upstream-v1.6.8rather thanmain. Merge #63 first and this retargets to a one-commit diff.Refs #34, #62.
What was left
"Capacity is always required, there is no unlimited" was settled on #34 and enforced in #62 — but as a single number on the event. Since v1.6.8 capacity is per-wave and
event.amount_ticketsis a derived roll-up, so the rule had nothing holding it up where organisers actually set it: the wave dialog's capacity input had no minimum, and the backend checked nothing at all. Themin="1"on the event-level field was the entire enforcement, and no API client is bound by an HTML attribute.A zero-capacity wave can never be active —
get_active_ticket_wavesrequiresamount_tickets > 0— so it is the wave-level form of exactly what #62 removed: an event that looks on sale but refuses every purchase, on the card and at checkout both.The rule
_validate_wave_capacityruns on create and update. Two details that matter more than the check itself:ensure_ticket_waves(data), not the raw list, so an event submitted with no waves is checked through the primary wave it is about to be given rather than passing vacuously.On update the check runs after the ownership check, so a non-owner still gets 403 rather than a validation message about someone else's event.
Frontend
The wave dialog's capacity input gains the
min="1"and hint the event-level field already had, and a new wave opens at1instead of0. That default uses??rather than||deliberately: a sold-out wave holds0and must keep showing it, or editing one would silently restore stock on save.Also drops the stale
0 = unlimited / not ticketedcontract still documented onCreateEvent.amount_tickets, which has not been true since #62.Still open on #34
This closes the capacity-required half only, so #34 stays open. The display-total question is undecided — the upstream review on that issue narrowed it to either dropping "X of Y" from the card (no schema change, survives waves untouched) or storing capacity in
extraJSON with an explicittickets_totaltag.aiolabs/webapp#143is the client-side half and is waiting on that same decision.Verification
6 new tests covering create, update, the synthesized-primary-wave path, a sold-out wave staying editable, a new wave added by an edit, and a legacy zero-capacity row. 120 pass. ruff, black, prettier clean; mypy error set unchanged from
main's baseline.Not yet exercised against a running instance — same aio-demo pass as #63 wants before
v1.6.8-aio.1.