def agenda( request: Request, db: Session = Depends(get_db), start_date: Optional[date] = None, end_date: Optional[date] = None, days: Optional[int] = None, ) -> _TemplateResponse: """Route for the agenda page, using dates range or exact amount of days.""" user_id = 1 # there is no user session yet, so I use user id- 1. start_date, end_date = calc_dates_range_for_agenda(start_date, end_date, days) events_objects = agenda_events.get_events_per_dates( db, user_id, start_date, end_date) events = defaultdict(list) for event_obj in events_objects: event_duration = agenda_events.get_time_delta_string( event_obj.start, event_obj.end) events[event_obj.start.date()].append((event_obj, event_duration)) return templates.TemplateResponse( "agenda.html", { "request": request, "events": events, "start_date": start_date, "end_date": end_date, })
def test_get_time_delta_string(self, start, end, diff): assert agenda_events.get_time_delta_string(start, end) == diff