forked from CGM_Public/pretix_original
Voucher get code validation
This commit is contained in:
@@ -44,8 +44,6 @@ class CodeColumn(ImportColumn):
|
|||||||
super().__init__(*args)
|
super().__init__(*args)
|
||||||
|
|
||||||
def clean(self, value, previous_values):
|
def clean(self, value, previous_values):
|
||||||
if not value:
|
|
||||||
raise ValidationError(_('A voucher cannot be created without a code.'))
|
|
||||||
if value:
|
if value:
|
||||||
MinLengthValidator(5)(value)
|
MinLengthValidator(5)(value)
|
||||||
if value and (value in self._cached or Voucher.objects.filter(event=self.event, code=value).exists()):
|
if value and (value in self._cached or Voucher.objects.filter(event=self.event, code=value).exists()):
|
||||||
|
|||||||
@@ -213,6 +213,8 @@ def import_vouchers(event: Event, fileid: str, settings: dict, locale: str, user
|
|||||||
voucher = Voucher(event=event)
|
voucher = Voucher(event=event)
|
||||||
vouchers.append(voucher)
|
vouchers.append(voucher)
|
||||||
|
|
||||||
|
if not record.get("code"):
|
||||||
|
raise ValidationError(_('A voucher cannot be created without a code.'))
|
||||||
Voucher.clean_item_properties(
|
Voucher.clean_item_properties(
|
||||||
record,
|
record,
|
||||||
event,
|
event,
|
||||||
|
|||||||
Reference in New Issue
Block a user