Skip to content

Commit 2d21039

Browse files
committed
make dates before 9/8/2020 and after 6/11/2021 invalid
1 parent 0d5d87f commit 2d21039

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

core/routes.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,11 @@ async def schoolweektoday(request):
268268
async def schoolweek(request, requested_date_str):
269269
# TODO: webscrape online calendar to get days off
270270
# TODO: possibly save days in sql db so email notifs can quickly access the day without processing all the info every time
271+
requested_date = date(*map(int, requested_date_str.split('-')))
271272
first_day = date(2020, 9, 8)
273+
if not first_day <= requested_date <= date(2021, 6, 11):
274+
abort(404, message=f'Requested URL {request.path} not found')
275+
272276
no_school = [
273277
date(2020, 9, 28), # Yom Kippur
274278
date(2020, 10, 12), # Columbus day
@@ -287,7 +291,6 @@ async def schoolweek(request, requested_date_str):
287291
0: 'B'
288292
}
289293

290-
requested_date = date(*map(int, requested_date_str.split('-')))
291294
next_friday = thisweek(requested_date)[-1]
292295
elapsed_dates = daterange(first_day, next_friday)
293296
mondays = [d for d in elapsed_dates if d.weekday() == 0 and d not in no_school]

core/templates/schoolweek.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ <h5>Maroon and gray A and B days for the week of {{ requested_date.strftime('%m/
1010
<label class="label" for="requested-date" style="margin-top: 5px;">Choose date</label>
1111
<input type="date" id="requested-date" name="requested-date"
1212
value="{{ requested_date }}"
13-
min="2020-09-05" max="2021-06-11" onchange="onDateChange(event);">
13+
min="2020-09-08" max="2021-06-11" onchange="onDateChange(event);">
1414
</div>
1515
<table>
1616
<tr class="week-calendar">

0 commit comments

Comments
 (0)