mirror of
https://github.com/pretix/pretix.git
synced 2026-05-05 15:14:04 +00:00
Voucher import: Fix validation quirks
This commit is contained in:
@@ -75,7 +75,7 @@ class MaxUsagesColumn(IntegerColumnMixin, ImportColumn):
|
||||
]
|
||||
|
||||
def clean(self, value, previous_values):
|
||||
if value is None:
|
||||
if value is None and previous_values.get("code"):
|
||||
raise ValidationError(_('The maximum number of usages must be set.'))
|
||||
return super().clean(value, previous_values)
|
||||
|
||||
|
||||
@@ -370,10 +370,11 @@ class Voucher(LoggedModel):
|
||||
'redeemed': redeemed
|
||||
}
|
||||
)
|
||||
if data.get('max_usages', 1) < data.get('min_usages', 1):
|
||||
raise ValidationError(
|
||||
_('The maximum number of usages may not be lower than the minimum number of usages.'),
|
||||
)
|
||||
if data.get('min_usages') is not None:
|
||||
if data.get('max_usages', 1) < data.get('min_usages', 1):
|
||||
raise ValidationError(
|
||||
_('The maximum number of usages may not be lower than the minimum number of usages.'),
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def clean_subevent(data, event):
|
||||
|
||||
Reference in New Issue
Block a user