django_program.registration.services.conditions¶
Condition evaluator service for the discount and condition engine.
Orchestrates evaluation of all active conditions for a user/cart context and returns applicable discounts as structured data for cart pricing integration.
All condition types are merged into a single priority-sorted list before evaluation so that priority ordering is respected globally across types.
Functions
|
Increment times_used for all stock-limited conditions that were applied. |
|
Evaluate all conditions for a cart. |
|
Evaluate all conditions against a list of cart items (side-effect free). |
|
Return all conditions the user currently qualifies for. |
|
Return ticket types and add-ons visible to this user. |
Classes
A discount applied to a single cart item by a condition. |
- class django_program.registration.services.conditions.CartItemDiscount[source]¶
Bases:
objectA discount applied to a single cart item by a condition.
- Parameters:
- django_program.registration.services.conditions.evaluate_for_items(items, user, conference)[source]¶
Evaluate all conditions against a list of cart items (side-effect free).
Gathers all active conditions into a single priority-sorted list, evaluates each against the user, and applies the first matching discount per item (no stacking). Does NOT mutate the database; call
commit_condition_usage()at checkout to persist usage.
- django_program.registration.services.conditions.evaluate_for_cart(cart)[source]¶
Evaluate all conditions for a cart.
Convenience wrapper around
evaluate_for_itemsthat fetches the cart’s items with related data.- Parameters:
cart (
Cart) – The cart to evaluate conditions for.- Return type:
- Returns:
A list of CartItemDiscount entries, one per discounted cart item.
- django_program.registration.services.conditions.commit_condition_usage(discounts)[source]¶
Increment times_used for all stock-limited conditions that were applied.
Call this at checkout time (not during cart summary viewing) to persist usage counts. Evaluation is side-effect free; this is the commit step.
Groups discounts by condition and increments
times_usedby the number of items each condition discounted. Uses a conditional UPDATE that only increments whenlimit=0 OR times_used + count <= limitto prevent overshooting the cap under concurrency.- Parameters:
discounts (
list[CartItemDiscount]) – The discount results fromevaluate_for_items.- Return type:
- django_program.registration.services.conditions.get_eligible_discounts(user, conference)[source]¶
Return all conditions the user currently qualifies for.
- Parameters:
- Return type:
- Returns:
A list of condition instances the user qualifies for.