mirror of
https://github.com/pretix/pretix.git
synced 2026-05-05 15:14:04 +00:00
Re-check maximum order size during _perform_order (Z#23213046) (#5586)
* Re-check maximum order size during _perform_order (Z#23213046) * Add test case
This commit is contained in:
@@ -146,6 +146,10 @@ error_messages = {
|
||||
'race_condition': gettext_lazy("This order was changed by someone else simultaneously. Please check if your "
|
||||
"changes are still accurate and try again."),
|
||||
'empty': gettext_lazy("Your cart is empty."),
|
||||
'max_items': ngettext_lazy(
|
||||
"You cannot select more than %s item per order.",
|
||||
"You cannot select more than %s items per order."
|
||||
),
|
||||
'max_items_per_product': ngettext_lazy(
|
||||
"You cannot select more than %(max)s item of the product %(product)s. We removed the surplus items from your cart.",
|
||||
"You cannot select more than %(max)s items of the product %(product)s. We removed the surplus items from your cart.",
|
||||
@@ -763,6 +767,11 @@ def _check_positions(event: Event, now_dt: datetime, time_machine_now_dt: dateti
|
||||
shared_lock_objects=[event]
|
||||
)
|
||||
|
||||
# Check maximum order size
|
||||
limit = min(int(event.settings.max_items_per_order), settings.PRETIX_MAX_ORDER_SIZE)
|
||||
if sum(1 for cp in sorted_positions if not cp.addon_to) > limit:
|
||||
err = err or (error_messages['max_items'] % limit)
|
||||
|
||||
# Check availability
|
||||
for i, cp in enumerate(sorted_positions):
|
||||
if cp.pk in deleted_positions:
|
||||
|
||||
Reference in New Issue
Block a user