From 81c251208c7db8fc4c38b911d139268592cb3dcd Mon Sep 17 00:00:00 2001 From: Raphael Michel Date: Mon, 23 May 2022 17:55:01 +0200 Subject: [PATCH] Cart API: Fix validation of subevent-bound vouchers --- src/pretix/api/serializers/cart.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pretix/api/serializers/cart.py b/src/pretix/api/serializers/cart.py index b49acd3c4f..0c02a14a28 100644 --- a/src/pretix/api/serializers/cart.py +++ b/src/pretix/api/serializers/cart.py @@ -142,7 +142,7 @@ class CartPositionCreateSerializer(I18nAwareModelSerializer): if voucher and voucher.seat and voucher.seat != validated_data.get('seat'): raise ValidationError('The specified voucher is not valid for this seat.') - if voucher and voucher.subevent_id and voucher.subevent_id != validated_data.get('subevent'): + if voucher and voucher.subevent_id and (not validated_data.get('subevent') or voucher.subevent_id != validated_data['subevent'].pk): raise ValidationError('The specified voucher is not valid for this subevent.') if voucher.valid_until is not None and voucher.valid_until < now():