Verified Commit 4fb2679b authored by David Haynes's avatar David Haynes 🙆
Browse files

Alter valid_end and valid_start to use DateTime

- in some silly scenarios, a schedule may come into effect on a date at a certain time
- this allows that to happen

Closes #70
parent ccade0a0
Pipeline #1713 passed with stage
in 1 minute and 41 seconds
...@@ -187,12 +187,13 @@ class Schedule(TimeStampedModel): ...@@ -187,12 +187,13 @@ class Schedule(TimeStampedModel):
# The start date of the schedule # The start date of the schedule
# (inclusive) # (inclusive)
valid_start = models.DateField('Start Date', null=True, blank=True, valid_start = models.DateTimeField('Start Date', null=True, blank=True,
help_text="Date that this schedule goes into effect") help_text="Date & time that this schedule goes into effect")
# The end date of the schedule # The end date of the schedule
# (inclusive) # (inclusive)
valid_end = models.DateField('End Date', null=True, blank=True, valid_end = models.DateTimeField('End Date', null=True, blank=True,
help_text="Last day that this schedule is in effect") help_text="Last date & time that this schedule is in effect")
# Boolean for if this schedule is 24 hours # Boolean for if this schedule is 24 hours
twenty_four_hours = models.BooleanField('24 hour schedule?', blank=True, twenty_four_hours = models.BooleanField('24 hour schedule?', blank=True,
default=False, help_text="Toggle to True if the Facility is open 24 hours. You do not need to specify any Open Times, it will always be displayed as open.") default=False, help_text="Toggle to True if the Facility is open 24 hours. You do not need to specify any Open Times, it will always be displayed as open.")
......
...@@ -509,7 +509,7 @@ class ScheduleViewSet(viewsets.ModelViewSet): ...@@ -509,7 +509,7 @@ class ScheduleViewSet(viewsets.ModelViewSet):
for schedule in Schedule.objects.all() for schedule in Schedule.objects.all()
# If the schedule ended before today # If the schedule ended before today
if schedule.valid_end and schedule.valid_start if schedule.valid_end and schedule.valid_start
if schedule.valid_end < datetime.date.today() if schedule.valid_end < datetime.today()
] ]
# Return all Schedule objects that have not expired # Return all Schedule objects that have not expired
return Schedule.objects.exclude(pk__in=filter_old_schedules) return Schedule.objects.exclude(pk__in=filter_old_schedules)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment