django_program.registration.services.capacity¶
Global ticket capacity enforcement for conferences.
Provides functions to count, check, and validate total ticket sales against a conference-level capacity limit. Add-ons are excluded from the global count because they do not consume venue seats.
Functions
|
Return the number of tickets still available under the global cap. |
|
Return the total number of tickets sold across all ticket types. |
|
Raise |
- django_program.registration.services.capacity.get_global_sold_count(conference)[source]¶
Return the total number of tickets sold across all ticket types.
Counts OrderLineItem quantities for ticket-type items (not add-ons) in orders that are PAID, PARTIALLY_REFUNDED, or PENDING with an active inventory hold.
Uses
addon__isnull=Truerather thanticket_type__isnull=Falseso that line items whose ticket type was deleted (SET_NULL) are still counted toward the sold total, preventing oversells.
- django_program.registration.services.capacity.get_global_remaining(conference)[source]¶
Return the number of tickets still available under the global cap.
- django_program.registration.services.capacity.validate_global_capacity(conference, desired_total)[source]¶
Raise
ValidationErrorifdesired_totalwould exceed global capacity.Acquires a row-level lock on the conference via
select_for_update()to prevent race conditions when multiple concurrent requests validate capacity at the same time. The caller must already be inside atransaction.atomicblock.The early-return check for unlimited conferences happens after the lock is acquired so that a stale in-memory instance cannot bypass enforcement.