From a69927da840125e994b975c87961c785f3a337c8 Mon Sep 17 00:00:00 2001 From: Mira Weller Date: Wed, 14 May 2025 18:34:09 +0200 Subject: [PATCH] formatting + comments --- src/pretix/base/services/cart.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/pretix/base/services/cart.py b/src/pretix/base/services/cart.py index e5cc47bcb8..ff340b461c 100644 --- a/src/pretix/base/services/cart.py +++ b/src/pretix/base/services/cart.py @@ -338,8 +338,9 @@ class CartManager: def _extend_expiry_of_valid_existing_positions(self): # Make sure we do not extend past the max_extend timestamp, allowing users to extend their valid positions up - # to 11 times the reservation time. After that, positions will expire, but can still be re-validated using - # ExtendOperation. + # to 11 times the reservation time. If we add new positions to the cart while valid positions exist, the new + # positions' reservation will also be limited to max_extend of the oldest position. + # Only after all positions expire, an ExtendOperation may reset max_extend to another 11x reservation_time. max_extend_existing = self.positions.filter(expires__gt=self.real_now_dt).aggregate(m=Min('max_extend'))['m'] if max_extend_existing: self._expiry = min(self._expiry, max_extend_existing) @@ -348,7 +349,11 @@ class CartManager: # Extend this user's cart session to ensure all items in the cart expire at the same time # We can extend the reservation of items which are not yet expired without risk if self._expiry > self.real_now_dt: - self.num_extended_positions += self.positions.filter(expires__gt=self.real_now_dt, expires__lt=self._expiry).update(expires=self._expiry) + self.num_extended_positions += self.positions.filter( + expires__gt=self.real_now_dt, expires__lt=self._expiry, + ).update( + expires=self._expiry, + ) def _delete_out_of_timeframe(self): err = None