Skip to content
Snippets Groups Projects

Reformat all files

Merged Jonathan Weth requested to merge reformat into master
5 files
+ 230
42
Compare changes
  • Side-by-side
  • Inline
Files
5
@@ -21,7 +21,9 @@ ExtraLesson = apps.get_model("chronos", "ExtraLesson")
def build_timetable(
type_: Union[TimetableType, str], obj: Union[int, Person], date_ref: Union[CalendarWeek, date],
type_: Union[TimetableType, str],
obj: Union[int, Person],
date_ref: Union[CalendarWeek, date],
):
needed_breaks = []
@@ -48,7 +50,9 @@ def build_timetable(
if is_person:
lesson_periods = LessonPeriod.objects.daily_lessons_for_person(obj, date_ref)
else:
lesson_periods = LessonPeriod.objects.in_week(date_ref).filter_from_type(type_, obj)
lesson_periods = LessonPeriod.objects.in_week(date_ref).filter_from_type(
type_, obj
)
# Sort lesson periods in a dict
lesson_periods_per_period = lesson_periods.group_by_periods(is_person=is_person)
@@ -57,7 +61,9 @@ def build_timetable(
if is_person:
extra_lessons = ExtraLesson.objects.on_day(date_ref).filter_from_person(obj)
else:
extra_lessons = ExtraLesson.objects.filter(week=date_ref.week).filter_from_type(type_, obj)
extra_lessons = ExtraLesson.objects.filter(week=date_ref.week).filter_from_type(
type_, obj
)
# Sort lesson periods in a dict
extra_lessons_per_period = extra_lessons.group_by_periods(is_person=is_person)
@@ -143,7 +149,10 @@ def build_timetable(
if period_after_break not in needed_breaks:
needed_breaks.append(period_after_break)
if not is_person and period_after_break not in supervisions_per_period_after:
if (
not is_person
and period_after_break not in supervisions_per_period_after
):
supervisions_per_period_after[period_after_break] = {}
if is_person:
@@ -169,7 +178,9 @@ def build_timetable(
if not is_person:
cols = []
for weekday in range(TimePeriod.weekday_min, TimePeriod.weekday_max + 1):
for weekday in range(
TimePeriod.weekday_min, TimePeriod.weekday_max + 1
):
col = None
if (
period in supervisions_per_period_after
@@ -198,21 +209,32 @@ def build_timetable(
if not is_person:
cols = []
for weekday in range(TimePeriod.weekday_min, TimePeriod.weekday_max + 1):
for weekday in range(
TimePeriod.weekday_min, TimePeriod.weekday_max + 1
):
col = []
# Add lesson periods
if period in lesson_periods_per_period and weekday not in holidays_per_weekday:
if (
period in lesson_periods_per_period
and weekday not in holidays_per_weekday
):
if weekday in lesson_periods_per_period[period]:
col += lesson_periods_per_period[period][weekday]
# Add extra lessons
if period in extra_lessons_per_period and weekday not in holidays_per_weekday:
if (
period in extra_lessons_per_period
and weekday not in holidays_per_weekday
):
if weekday in extra_lessons_per_period[period]:
col += extra_lessons_per_period[period][weekday]
# Add events
if period in events_per_period and weekday not in holidays_per_weekday:
if (
period in events_per_period
and weekday not in holidays_per_weekday
):
if weekday in events_per_period[period]:
col += events_per_period[period][weekday]
@@ -309,7 +331,9 @@ def build_substitutions_list(wanted_day: date) -> List[dict]:
return rows
def build_weekdays(base: List[Tuple[int, str]], wanted_week: CalendarWeek) -> List[dict]:
def build_weekdays(
base: List[Tuple[int, str]], wanted_week: CalendarWeek
) -> List[dict]:
holidays_per_weekday = Holiday.in_week(wanted_week)
weekdays = []
@@ -319,7 +343,9 @@ def build_weekdays(base: List[Tuple[int, str]], wanted_week: CalendarWeek) -> Li
"key": key,
"name": name,
"date": wanted_week[key],
"holiday": holidays_per_weekday[key] if key in holidays_per_weekday else None,
"holiday": holidays_per_weekday[key]
if key in holidays_per_weekday
else None,
}
weekdays.append(weekday)
Loading