Skip to content
Snippets Groups Projects
Verified Commit de33dc2d authored by Jonathan Weth's avatar Jonathan Weth :keyboard:
Browse files

Update timetable printing for lesson bundles

parent c9c874ce
No related branches found
No related tags found
1 merge request!36Draft: Resolve "[New data model] PDF export for "regular" timetable"
from collections.abc import Iterable
from datetime import time from datetime import time
from typing import Iterable, Optional, Union from typing import Optional, Union
from django.db.models import Max, Min, Q, QuerySet from django.db.models import Max, Min, Q, QuerySet
from django.db.models.functions import Coalesce from django.db.models.functions import Coalesce
......
...@@ -25,11 +25,13 @@ def build_timetable( ...@@ -25,11 +25,13 @@ def build_timetable(
max_slots = len(max_slots) max_slots = len(max_slots)
# Get matching lessons # Get matching lessons
lessons = Lesson.objects.filter(slot_start__time_grid=time_grid).filter_from_type(type_, obj) lessons = Lesson.objects.filter(bundle__slot_start__time_grid=time_grid).filter_from_type(
type_, obj
)
# Sort lesson periods in a dict # Sort lesson periods in a dict
for lesson in lessons: for lesson in lessons:
lesson_periods_per_slot[lesson.slot_start].append(lesson) lesson_periods_per_slot[lesson.bundle.all()[0].slot_start].append(lesson)
# Get matching supervisions # Get matching supervisions
supervisions = Supervision.objects.filter(break_slot__time_grid=time_grid).filter_from_type( supervisions = Supervision.objects.filter(break_slot__time_grid=time_grid).filter_from_type(
...@@ -65,9 +67,7 @@ def build_timetable( ...@@ -65,9 +67,7 @@ def build_timetable(
col = { col = {
"type": "period", "type": "period",
"col": ( "col": (
lesson_periods_per_slot[actual_slot] lesson_periods_per_slot.get(actual_slot, [])
if actual_slot in lesson_periods_per_slot
else []
), ),
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment