Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
SRCT
whats-open
Commits
e3b2dafd
Verified
Commit
e3b2dafd
authored
Jul 08, 2017
by
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
Changes
1
Hide whitespace changes
Inline
Side-by-side
whats-open/api/models.py
View file @
e3b2dafd
...
...
@@ -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"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment