forked from CGM_Public/pretix_original
Added some validation to the Event model
This commit is contained in:
@@ -2,6 +2,7 @@ import uuid
|
|||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
from django.core.exceptions import ValidationError
|
||||||
from django.core.validators import RegexValidator
|
from django.core.validators import RegexValidator
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.template.defaultfilters import date as _date
|
from django.template.defaultfilters import date as _date
|
||||||
@@ -101,6 +102,13 @@ class Event(Versionable):
|
|||||||
self.get_cache().clear()
|
self.get_cache().clear()
|
||||||
return obj
|
return obj
|
||||||
|
|
||||||
|
def clean(self):
|
||||||
|
if self.presale_start and self.presale_end and self.presale_start > self.presale_end:
|
||||||
|
raise ValidationError({'presale_end': _('The end of the presale period has to be later than it\'s start.')})
|
||||||
|
if self.date_from and self.date_to and self.date_from > self.date_to:
|
||||||
|
raise ValidationError({'date_to': _('The end of the event has to be later than it\'s start.')})
|
||||||
|
super().clean()
|
||||||
|
|
||||||
def get_plugins(self) -> "list[str]":
|
def get_plugins(self) -> "list[str]":
|
||||||
"""
|
"""
|
||||||
Get the names of the plugins activated for this event as a list.
|
Get the names of the plugins activated for this event as a list.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
from itertools import product
|
|
||||||
import sys
|
import sys
|
||||||
|
from itertools import product
|
||||||
|
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.db.models import Q, Case, Count, Sum, When
|
from django.db.models import Q, Case, Count, Sum, When
|
||||||
|
|||||||
Reference in New Issue
Block a user