mirror of
https://github.com/pretix/pretix.git
synced 2026-05-18 17:24:03 +00:00
only display success message if actual extension performed
This commit is contained in:
@@ -294,6 +294,7 @@ class CartManager:
|
|||||||
self.invoice_address = invoice_address
|
self.invoice_address = invoice_address
|
||||||
self._widget_data = widget_data or {}
|
self._widget_data = widget_data or {}
|
||||||
self._sales_channel = sales_channel
|
self._sales_channel = sales_channel
|
||||||
|
self.num_extended_positions = 0
|
||||||
|
|
||||||
if expiry and reservation_time:
|
if expiry and reservation_time:
|
||||||
raise TypeError('Cannot specify both expiry and reservation_time')
|
raise TypeError('Cannot specify both expiry and reservation_time')
|
||||||
@@ -347,7 +348,7 @@ class CartManager:
|
|||||||
# Extend this user's cart session to ensure all items in the cart expire at the same time
|
# 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
|
# We can extend the reservation of items which are not yet expired without risk
|
||||||
if self._expiry > self.real_now_dt:
|
if self._expiry > self.real_now_dt:
|
||||||
self.positions.filter(expires__gt=self.real_now_dt).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):
|
def _delete_out_of_timeframe(self):
|
||||||
err = None
|
err = None
|
||||||
@@ -606,6 +607,7 @@ class CartManager:
|
|||||||
self._voucher_use_diff[cp.voucher] += 2
|
self._voucher_use_diff[cp.voucher] += 2
|
||||||
|
|
||||||
self._operations.append(op)
|
self._operations.append(op)
|
||||||
|
self.num_extended_positions += 1
|
||||||
return err
|
return err
|
||||||
|
|
||||||
def apply_voucher(self, voucher_code: str):
|
def apply_voucher(self, voucher_code: str):
|
||||||
@@ -1667,6 +1669,7 @@ def extend_cart_reservation(self, event: Event, cart_id: str=None, locale='en',
|
|||||||
try:
|
try:
|
||||||
cm = CartManager(event=event, cart_id=cart_id, sales_channel=sales_channel)
|
cm = CartManager(event=event, cart_id=cart_id, sales_channel=sales_channel)
|
||||||
cm.commit()
|
cm.commit()
|
||||||
|
return cm.num_extended_positions
|
||||||
except LockTimeoutException:
|
except LockTimeoutException:
|
||||||
self.retry()
|
self.retry()
|
||||||
except (MaxRetriesExceededError, LockTimeoutException):
|
except (MaxRetriesExceededError, LockTimeoutException):
|
||||||
|
|||||||
@@ -543,7 +543,8 @@ class CartExtendReservation(EventViewMixin, CartActionMixin, AsyncAction, View):
|
|||||||
known_errortypes = ['CartError']
|
known_errortypes = ['CartError']
|
||||||
|
|
||||||
def get_success_message(self, value):
|
def get_success_message(self, value):
|
||||||
return _('Your cart timeout was extended.')
|
if value > 0:
|
||||||
|
return _('Your cart timeout was extended.')
|
||||||
|
|
||||||
def post(self, request, *args, **kwargs):
|
def post(self, request, *args, **kwargs):
|
||||||
return self.do(self.request.event.id, get_or_create_cart_id(self.request), translation.get_language(),
|
return self.do(self.request.event.id, get_or_create_cart_id(self.request), translation.get_language(),
|
||||||
|
|||||||
Reference in New Issue
Block a user