Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Commit

Permalink
Fix sanity-checks for all-day events (and thereby publishing)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmurty committed Oct 18, 2016
1 parent 45e51d7 commit d5a16a2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 20 deletions.
15 changes: 4 additions & 11 deletions icekit_events/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 0 additions & 9 deletions icekit_events/tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit d5a16a2

Please sign in to comment.