From 7639ef9a42b74df3fb6f3b98542411c509116e52 Mon Sep 17 00:00:00 2001 From: Raphael Michel Date: Wed, 21 Dec 2016 16:28:33 +0100 Subject: [PATCH] Protect against empty orders --- src/pretix/base/services/orders.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/pretix/base/services/orders.py b/src/pretix/base/services/orders.py index 752edaa7d0..a2a75d4ccb 100644 --- a/src/pretix/base/services/orders.py +++ b/src/pretix/base/services/orders.py @@ -43,6 +43,7 @@ error_messages = { 'price_changed': _('The price of some of the items in your cart has changed in the ' 'meantime. Please see below for details.'), 'internal': _("An internal error occured, please try again."), + 'empty': _("Your cart is empty."), 'busy': _('We were not able to process your request completely as the ' 'server was too busy. Please try again.'), 'not_started': _('The presale period for this event has not yet started.'), @@ -345,6 +346,8 @@ def _perform_order(event: str, payment_provider: str, position_ids: List[str], with event.lock() as now_dt: positions = list(CartPosition.objects.filter( id__in=position_ids).select_related('item', 'variation')) + if len(positions) == 0: + raise OrderError(error_messages['empty']) if len(position_ids) != len(positions): raise OrderError(error_messages['internal']) _check_positions(event, now_dt, positions)