From 2fd2462ef1fe36264c89b45182150e9184e96174 Mon Sep 17 00:00:00 2001 From: Raphael Michel Date: Fri, 25 Feb 2022 18:12:28 +0100 Subject: [PATCH] Voucher bulk creation: Fix validation for duplicate in input --- src/pretix/control/forms/vouchers.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/pretix/control/forms/vouchers.py b/src/pretix/control/forms/vouchers.py index 936f58f1ee..dbe05b0504 100644 --- a/src/pretix/control/forms/vouchers.py +++ b/src/pretix/control/forms/vouchers.py @@ -385,6 +385,12 @@ class VoucherBulkForm(VoucherForm): if vouchers.exists(): raise ValidationError(_('A voucher with one of these codes already exists.')) + codes_seen = set() + for c in data['codes']: + if c in codes_seen: + raise ValidationError(_('The voucher code {code} appears in your list twice.').format(code=c)) + codes_seen.add(c) + if data.get('send') and not all([data.get('send_subject'), data.get('send_message'), data.get('send_recipients')]): raise ValidationError(_('If vouchers should be sent by email, subject, message and recipients need to be specified.'))