def schedule_day_from_date(request, day_start): """The day-at-a-glance schedule view, with the day specfied by a date object (including the start time of the schedule). """ this_year, this_week, this_day = day_start.isocalendar() next_start = day_start + timedelta(days=1) next_year, next_week, next_day = next_start.isocalendar() prev_start = day_start - timedelta(days=1) prev_year, prev_week, prev_day = prev_start.isocalendar() term = Term.of(day_start) schedule = None if not term else ScheduleRange.day( day_start, exclude_before_start=False, exclude_after_end=False, exclude_subsuming=False, with_filler_timeslots=True).data return render( request, 'schedule/schedule-day.html', {'day_start': day_start, 'this_year': this_year, 'this_week': this_week, 'next_start': next_start, 'next_year': next_year, 'next_week': next_week, 'next_day': next_day, 'prev_start': prev_start, 'prev_year': prev_year, 'prev_week': prev_week, 'prev_day': prev_day, 'term': term, 'schedule': schedule})
def schedule_week_from_date(request, week_start): """The week-at-a-glance schedule view, with the week specified by a date object denoting its starting day. """ this_year, this_week, this_day = week_start.isocalendar() next_start = week_start + timedelta(weeks=1) next_year, next_week, next_day = next_start.isocalendar() prev_start = week_start - timedelta(weeks=1) prev_year, prev_week, prev_day = prev_start.isocalendar() term = Term.of(week_start) schedule = None if not term else WeekTable.tabulate( ScheduleRange.week( week_start, split_days=True, exclude_before_start=False, exclude_after_end=False, exclude_subsuming=False, with_filler_timeslots=True)) return render( request, 'schedule/schedule-week.html', {'week_start': week_start, 'this_year': this_year, 'this_week': this_week, 'next_start': next_start, 'next_year': next_year, 'next_week': next_week, 'prev_start': prev_start, 'prev_year': prev_year, 'prev_week': prev_week, 'term': term, 'schedule': schedule})