forked from CGM_Public/pretix_original
Mention offending item in QuotaExceededException message
This commit is contained in:
@@ -310,7 +310,7 @@ class Order(LoggedModel):
|
|||||||
|
|
||||||
def _is_still_available(self, now_dt: datetime=None) -> Union[bool, str]:
|
def _is_still_available(self, now_dt: datetime=None) -> Union[bool, str]:
|
||||||
error_messages = {
|
error_messages = {
|
||||||
'unavailable': _('Some of the ordered products are no longer available.'),
|
'unavailable': _('The ordered product "{item}" is no longer available.'),
|
||||||
}
|
}
|
||||||
now_dt = now_dt or now()
|
now_dt = now_dt or now()
|
||||||
positions = self.positions.all().select_related('item', 'variation')
|
positions = self.positions.all().select_related('item', 'variation')
|
||||||
@@ -332,7 +332,9 @@ class Order(LoggedModel):
|
|||||||
quota.cached_availability -= 1
|
quota.cached_availability -= 1
|
||||||
if quota.cached_availability < 0:
|
if quota.cached_availability < 0:
|
||||||
# This quota is sold out/currently unavailable, so do not sell this at all
|
# This quota is sold out/currently unavailable, so do not sell this at all
|
||||||
raise Quota.QuotaExceededException(error_messages['unavailable'])
|
raise Quota.QuotaExceededException(error_messages['unavailable'].format(
|
||||||
|
item=str(op.item) + (' - ' + str(op.variation) if op.variation else '')
|
||||||
|
))
|
||||||
except Quota.QuotaExceededException as e:
|
except Quota.QuotaExceededException as e:
|
||||||
return str(e)
|
return str(e)
|
||||||
return True
|
return True
|
||||||
|
|||||||
Reference in New Issue
Block a user