forked from CGM_Public/pretix_original
Questions: validate that min < max (#4992)
* Questions: validate that min < max * Update src/pretix/base/models/items.py Co-authored-by: Richard Schreiber <schreiber@rami.io> --------- Co-authored-by: Richard Schreiber <schreiber@rami.io>
This commit is contained in:
@@ -1915,6 +1915,15 @@ class Question(LoggedModel):
|
||||
if event != item.event:
|
||||
raise ValidationError(_('One or more items do not belong to this event.'))
|
||||
|
||||
def clean(self):
|
||||
if self.valid_date_max and self.valid_date_min and self.valid_date_min > self.valid_date_max:
|
||||
raise ValidationError(_("The maximum date must not be before the minimum value."))
|
||||
if self.valid_datetime_max and self.valid_datetime_min and self.valid_datetime_min > self.valid_datetime_max:
|
||||
raise ValidationError(_("The maximum date must not be before the minimum value."))
|
||||
if self.valid_number_max and self.valid_number_min and self.valid_number_min > self.valid_number_max:
|
||||
raise ValidationError(_("The maximum value must not be lower than the minimum value."))
|
||||
super().clean()
|
||||
|
||||
|
||||
class QuestionOption(models.Model):
|
||||
question = models.ForeignKey('Question', related_name='options', on_delete=models.CASCADE)
|
||||
|
||||
Reference in New Issue
Block a user