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

Correctly assign rooms to lesson parts

(cherry picked from commit 7645d34d)
parent bbb48f7c
No related branches found
No related tags found
1 merge request!88Prepare release 2.0rc3
......@@ -18,6 +18,7 @@ Fixed
~~~~~
* Skip extra lessons without a subject.
* Fix problems with lesson parts without a room and lesson parts with two courses and one teacher in a room.
`2.0rc2`_ - 2021-07-30
----------------------
......
......@@ -63,12 +63,16 @@ def import_lessons(
for el in raw_time_data_2:
weekday = int(el[1]) - 1
hour = int(el[2])
room_ids = untis_split_third(el[3], conv=int)
room_ids = list(filter(lambda r: r != "", el[3].split(";")))
# Get rooms
rooms = []
for room_id in room_ids:
r = rooms_ref[room_id]
if room_id and room_id != "0":
room_id = int(room_id)
r = rooms_ref[room_id]
else:
r = None
rooms.append(r)
# Get time period
......@@ -81,6 +85,8 @@ def import_lessons(
for el in raw_lesson_data:
raw_lesson_data_2.append(el.split("~"))
use_room_idx = 0
current_teacher_id = None
# All part lessons (courses)
for i, el in enumerate(raw_lesson_data_2):
logger.info(" Lesson part {}".format(i))
......@@ -105,6 +111,9 @@ def import_lessons(
logger.warning(_(" Skip because missing subject"))
continue
if current_teacher_id and current_teacher_id != teacher_id:
use_room_idx += 1
# Get classes
course_classes = []
for class_id in class_ids:
......@@ -235,8 +244,8 @@ def import_lessons(
# Get room if provided
rooms = rooms_per_periods[j]
if i < len(rooms):
room = rooms[i]
if use_room_idx < len(rooms):
room = rooms[use_room_idx]
else:
room = None
......@@ -259,6 +268,8 @@ def import_lessons(
)
logger.info(" New time period added")
current_teacher_id = teacher_id
for lesson in chronos_models.Lesson.objects.filter(validity=validity_range):
if lesson.lesson_id_untis and lesson.lesson_id_untis not in existing_lessons:
logger.info("Lesson {} deleted".format(lesson.id))
......
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