Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add config to omit some weekdays #41

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions warp/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ class DefaultSettings(object):
# (after the current week)
WEEKS_IN_ADVANCE = 1

# Weekdays to hide for reservation, 0 for monday to 6 for sunday
# Set to [5,6] to omit weekends
OMITTED_WEEKDAYS = []

MAX_CONTENT_LENGTH = 5 * 1024 * 1024

# maximum size of uploaded map file
Expand Down
14 changes: 8 additions & 6 deletions warp/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,18 @@ def getNextWeek():
noOfSundays = 0

weeksInAdvance = flask.current_app.config['WEEKS_IN_ADVANCE']
omittedWeekdays = flask.current_app.config['OMITTED_WEEKDAYS']

while noOfSundays <= weeksInAdvance:

t = gmtime(ts)
res.append( {
"timestamp": ts,
"date": strftime("%Y-%m-%d",t),
"weekdayN": strftime("%w",t),
"isWeekend": t.tm_wday>=5
})
if t.tm_wday not in omittedWeekdays:
res.append( {
"timestamp": ts,
"date": strftime("%Y-%m-%d",t),
"weekdayN": strftime("%w",t),
"isWeekend": t.tm_wday>=5
})

ts = ts + 24*3600

Expand Down