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

Set subject, teacher, and room only when found (during exams import)

parent 2fde0c70
No related branches found
No related tags found
No related merge requests found
......@@ -87,7 +87,7 @@ def import_exams(
lesson_id = int(el[0])
subject_id = int(el[1])
lesson = Lesson.objects.get(validity=validity_range, lesson_id_untis=lesson_id)
subject = subjects_ref[subject_id]
subject = subjects_ref[subject_id] if subject_id in subjects_ref else None
first = False
period = int(el[4])
if not period:
......@@ -96,8 +96,8 @@ def import_exams(
period = time_periods_ref[weekday][period]
teacher_id = int(el[5])
room_id = int(el[6])
teacher = teachers_ref[teacher_id]
room = rooms_ref[room_id]
teacher = teachers_ref[teacher_id] if teacher_id in teachers_ref else None
room = rooms_ref[room_id] if room_id in rooms_ref else None
exams.append((period, teacher, room))
if not lesson or not subject or not exams:
......
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