Show better error message if a gift card is used in apply_voucher

This commit is contained in:
Raphael Michel
2022-05-11 17:06:20 +02:00
parent 351e06168e
commit ed4bc87198

View File

@@ -447,7 +447,10 @@ class CartManager:
try:
voucher = self.event.vouchers.get(code__iexact=voucher_code.strip())
except Voucher.DoesNotExist:
raise CartError(error_messages['voucher_invalid'])
if self.event.organizer.accepted_gift_cards.filter(secret__iexact=voucher_code).exists():
raise CartError(error_messages['gift_card'])
else:
raise CartError(error_messages['voucher_invalid'])
voucher_use_diff = Counter()
ops = []