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

Add function that cleans old schedules

- there's no scenario where anyone wants to deal with schedules
that have expired
parent 1adad031
......@@ -148,6 +148,16 @@ class Facility(TimeStampedModel):
# Closed
return False
def clean_special_schedules(self):
"""
Loop through every special_schedule and remove entries that have
expired.
"""
for special_schedule in self.special_schedules.all():
# If it ends before today
if special_schedule.valid_end < datetime.date.today():
self.special_schedules.remove(special_schedule)
class Meta:
verbose_name = "facility"
verbose_name_plural = "facilities"
......
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