From d5a16a2415c374a8bfc571f3e1a1b61b78b4ac10 Mon Sep 17 00:00:00 2001 From: James Murty Date: Wed, 19 Oct 2016 08:16:14 +1100 Subject: [PATCH] Fix sanity-checks for all-day events (and thereby publishing) --- icekit_events/models.py | 15 ++++----------- icekit_events/tests/tests.py | 9 --------- 2 files changed, 4 insertions(+), 20 deletions(-) diff --git a/icekit_events/models.py b/icekit_events/models.py index 17ac417..37b29e2 100644 --- a/icekit_events/models.py +++ b/icekit_events/models.py @@ -606,19 +606,12 @@ def save(self, *args, **kwargs): if self.is_all_day: # An all-day generator's start time must be at 00:00 - if self.start.hour or self.start.minute or self.start.second \ - or self.start.microsecond: + naive_start = coerce_naive(self.start) + if naive_start.hour or naive_start.minute or naive_start.second \ + or naive_start.microsecond: raise GeneratorException( 'Start date/time must be at 00:00:00 hours/minutes/seconds' - ' for all-day generators: {0}'.format(self.start) - ) - - # An all-day generator duration must be a whole multiple of days - duration = self.duration - if duration.seconds or duration.microseconds: - raise GeneratorException( - 'Duration between start and end times must be multiples of' - ' a day for all-day generators: {0}'.format(self.duration) + ' for all-day generators: {0}'.format(naive_start) ) # Convert datetime field values to date-compatible versions in the diff --git a/icekit_events/tests/tests.py b/icekit_events/tests/tests.py index a17bf2d..05634a7 100644 --- a/icekit_events/tests/tests.py +++ b/icekit_events/tests/tests.py @@ -831,15 +831,6 @@ def test_save_checks(self): end=self.start + timedelta(hours=24), event=G(SimpleEvent), ) - self.assertRaisesRegexp( - models.GeneratorException, - 'Duration between start and end times must be multiples of a day' - ' for all-day generators', - models.EventRepeatsGenerator.objects.create, - is_all_day=True, - start=self.start, - end=self.start + timedelta(hours=24, seconds=1), - ) def test_duration(self): self.assertEquals(