FIX: Prevent setting access time after start time

Cherry pick of d274ea4606. Will close #405.
This commit is contained in:
2020-05-25 01:16:26 +01:00
parent 544b6df35c
commit e6d06db2a1
2 changed files with 35 additions and 1 deletions

View File

@@ -463,6 +463,12 @@ class Event(models.Model, RevisionMixin):
hasStartAndEnd = self.has_start_time and self.has_end_time
if startEndSameDay and hasStartAndEnd and self.start_time > self.end_time:
raise ValidationError('Unless you\'ve invented time travel, the event can\'t finish before it has started.')
if self.access_at is not None:
if self.access_at.date() > self.start_date:
raise ValidationError('Regardless of what some clients might think, access time cannot be after the event has started.')
elif self.start_time is not None and self.start_date == self.access_at.date() and self.access_at.time() > self.start_time:
raise ValidationError('Regardless of what some clients might think, access time cannot be after the event has started.')
def save(self, *args, **kwargs):
"""Call :meth:`full_clean` before saving."""