try:
conn, site, params = self._init_handling()
if 'calendar' == site:
- html = self.do_GET_calendar(conn)
+ start = params.get('start', [''])[0]
+ end = params.get('end', [''])[0]
+ html = self.do_GET_calendar(conn, start, end)
elif 'day' == site:
date = params.get('date', [todays_date()])[0]
html = self.do_GET_day(conn, date)
except HandledException as error:
self._send_msg(error)
- def do_GET_calendar(self, conn: DatabaseConnection):
+ def do_GET_calendar(self, conn: DatabaseConnection, start: str, end: str):
"""Show Days."""
return self.server.jinja.get_template('calendar.html').render(
- days=Day.all(conn))
+ days=Day.all(conn, date_range=(start, end)))
def do_GET_day(self, conn: DatabaseConnection, date: str):
"""Show single Day."""
self.assertEqual(http_conn.getresponse().status, 400)
http_conn.request('GET', '/calendar')
self.assertEqual(http_conn.getresponse().status, 200)
+ http_conn.request('GET', '/calendar?start=&end=')
+ self.assertEqual(http_conn.getresponse().status, 200)
+ http_conn.request('GET', '/calendar?start=today&end=today')
+ self.assertEqual(http_conn.getresponse().status, 200)
+ http_conn.request('GET', '/calendar?start=2024-01-01&end=2025-01-01')
+ self.assertEqual(http_conn.getresponse().status, 200)
+ http_conn.request('GET', '/calendar?start=foo')
+ self.assertEqual(http_conn.getresponse().status, 400)
def tearDown(self):
self.httpd.shutdown()