Commit 0e3bb640 authored by David Haynes's avatar David Haynes 🙆
Browse files

Merge branch '68-non-expiring' into '2.1-dev'

Resolve "Special Schedules that do not expire"

See merge request !29
parents 89e3f4f1 e590815f
......@@ -63,7 +63,8 @@ class ScheduleAdmin(admin.ModelAdmin):
# Pair valid_start and valid_end together on the same
# line
('valid_start', 'valid_end'),
......@@ -162,7 +162,7 @@ class Facility(TimeStampedModel):
for special_schedule in self.special_schedules.all():
# If it ends before today
if special_schedule.valid_end <
if special_schedule.valid_end < and special_schedule.schedule_for_removal:
class Meta:
......@@ -198,6 +198,10 @@ class Schedule(TimeStampedModel):
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.")
# Boolean for if this schedule should never be removed.
schedule_for_removal = models.BooleanField('Schedule for removal', blank=False,
default=True, help_text="Toggle to False if the schedule should never be removed in the backend. By default, all schedules are automatically deleted after they have expired.")
def is_open_now(self):
Return true if this schedule is open right now.
......@@ -66,7 +66,7 @@ class ScheduleSerializer(serializers.ModelSerializer):
model = Schedule
# List the fields that we are serializing
fields = ('id', 'open_times', 'modified', 'name', 'valid_start',
'valid_end', 'twenty_four_hours')
'valid_end', 'twenty_four_hours', 'schedule_for_removal')
class FacilitySerializer(serializers.HyperlinkedModelSerializer):
......@@ -376,10 +376,12 @@ class FacilityViewSet(viewsets.ReadOnlyModelViewSet):
# Associate a serializer with the ViewSet
......@@ -485,7 +487,8 @@ class ScheduleViewSet(viewsets.ModelViewSet):
# Associate a serializer with the ViewSet
......@@ -509,7 +512,7 @@ class ScheduleViewSet(viewsets.ModelViewSet):
for schedule in Schedule.objects.all()
# If the schedule ended before today
if schedule.valid_end and schedule.valid_start
if schedule.valid_end <
if schedule.valid_end <
# Return all Schedule objects that have not expired
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