forked from CGM_Public/pretix_original
Improved voucher interface with new methods (#284)
* Check that a voucher's variation matches its item * Add method to check applicability of a voucher * Add method to check if a voucher can be used * Add tests for new voucher methods * Test for ValidationErrors in Voucher.clean() * Test for voucher state during ordering process
This commit is contained in:
committed by
Raphael Michel
parent
853510a375
commit
aa63a4cded
@@ -117,9 +117,7 @@ def _add_new_items(event: Event, items: List[dict],
|
||||
return error_messages['voucher_redeemed']
|
||||
if voucher.valid_until is not None and voucher.valid_until < now_dt:
|
||||
return error_messages['voucher_expired']
|
||||
if voucher.item and voucher.item.pk != item.pk:
|
||||
return error_messages['voucher_invalid_item']
|
||||
if voucher.variation and (not variation or variation.pk != voucher.variation.pk):
|
||||
if not voucher.applies_to(item, variation):
|
||||
return error_messages['voucher_invalid_item']
|
||||
doubleuse = CartPosition.objects.filter(voucher=voucher, cart_id=cart_id, event=event)
|
||||
if 'cp' in i:
|
||||
|
||||
Reference in New Issue
Block a user