mirror of
https://github.com/pretix/pretix.git
synced 2026-05-08 15:44:02 +00:00
Bulk add vouchers: Require codes to be entered
This commit is contained in:
@@ -88,7 +88,8 @@ class VoucherBulkForm(VoucherForm):
|
|||||||
label=_("Codes"),
|
label=_("Codes"),
|
||||||
help_text=_(
|
help_text=_(
|
||||||
"Add one voucher code per line. We suggest that you copy this list and save it into a file."
|
"Add one voucher code per line. We suggest that you copy this list and save it into a file."
|
||||||
)
|
),
|
||||||
|
required=True
|
||||||
)
|
)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
@@ -100,7 +101,7 @@ class VoucherBulkForm(VoucherForm):
|
|||||||
|
|
||||||
def clean(self):
|
def clean(self):
|
||||||
data = super().clean()
|
data = super().clean()
|
||||||
data['codes'] = [a.strip() for a in data['codes'].strip().split("\n")]
|
data['codes'] = [a.strip() for a in data.get('codes', '').strip().split("\n") if a]
|
||||||
|
|
||||||
if Voucher.objects.filter(code__in=data['codes'], event=self.instance.event).exists():
|
if Voucher.objects.filter(code__in=data['codes'], event=self.instance.event).exists():
|
||||||
raise ValidationError(_('A voucher with one of this codes already exists.'))
|
raise ValidationError(_('A voucher with one of this codes already exists.'))
|
||||||
|
|||||||
Reference in New Issue
Block a user