From d274ea46064058059e22c8fda2af28cfb360ee67 Mon Sep 17 00:00:00 2001 From: FreneticScribbler Date: Tue, 3 Mar 2020 20:04:02 +0000 Subject: [PATCH] FIX: Prevent setting access time after start time Will close #405 --- RIGS/models.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/RIGS/models.py b/RIGS/models.py index 0b97ca61..0efc915e 100644 --- a/RIGS/models.py +++ b/RIGS/models.py @@ -486,6 +486,10 @@ class Event(models.Model, RevisionMixin): 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.') + accessAndStartSameDay = self.start_date == self.access_at.date() + if self.access_at.date() > self.start_date or (accessAndStartSameDay 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.""" self.full_clean()