From fe2e01938a459f9c25b99ca52217b80aa2a32ff9 Mon Sep 17 00:00:00 2001 From: Raphael Michel Date: Wed, 9 Jun 2021 17:42:07 +0200 Subject: [PATCH] Orders API: Silently fail if an answer to a question is submitted twice --- src/pretix/api/serializers/order.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/pretix/api/serializers/order.py b/src/pretix/api/serializers/order.py index bc2de23899..bad458092e 100644 --- a/src/pretix/api/serializers/order.py +++ b/src/pretix/api/serializers/order.py @@ -1292,7 +1292,13 @@ class OrderCreateSerializer(I18nAwareModelSerializer): if pos.voucher: Voucher.objects.filter(pk=pos.voucher.pk).update(redeemed=F('redeemed') + 1) pos.save() + seen_answers = set() for answ_data in answers_data: + # Workaround for a pretixPOS bug :-( + if answ_data.get('question') in seen_answers: + continue + seen_answers.add(answ_data.get('question')) + options = answ_data.pop('options', []) if isinstance(answ_data['answer'], File):