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

Bug fix

parent 9f9d5a47
No related branches found
No related tags found
No related merge requests found
......@@ -172,25 +172,25 @@ def get_lesson_element_by_id_and_teacher(lesson_id, teacher, hour=None, weekday=
return None, None
el = None
i = 0
# print(lesson.elements)
for i, element in enumerate(lesson.elements):
# print(element.teacher.shortcode)
if element.teacher.id == teacher.id:
el = element
break
if teacher is not None:
for i, element in enumerate(lesson.elements):
if element.teacher is not None:
if element.teacher.id == teacher.id:
el = element
break
elif len(lesson.elements) > 0:
el = lesson.elements[0]
else:
el = None
t = None
# print(lesson.times)
# print(weekday)
# print(hour)
for time in lesson.times:
# print("DAY", time.day, time.hour)
if time.day == weekday and time.hour == hour:
t = time
# print(t)
room = None
if t is not None and len(t.rooms) > i:
# print(t.rooms)
# print(len(t.rooms))
room = t.rooms[i]
if el is not None:
......
......@@ -65,6 +65,7 @@ class Substitution(object):
if db_obj.teacher_idlessn != 0:
self.teacher_old = drive["teachers"][db_obj.teacher_idlessn]
# print(self.teacher_new, self.teacher_old, self.lesson_id, self.id)
if db_obj.teacher_idsubst != 0:
self.teacher_new = drive["teachers"][db_obj.teacher_idsubst]
......@@ -75,6 +76,8 @@ class Substitution(object):
self.teacher_old = self.teacher_new
self.teacher_new = None
print(self.teacher_old, self.teacher_new)
self.lesson_element, self.room_old = get_lesson_element_by_id_and_teacher(self.lesson_id, self.teacher_old,
self.lesson, self.date.weekday() + 1)
# print(self.lesson)
......@@ -149,7 +152,9 @@ class SubRow(object):
def generate_teacher_row(sub, full=False):
# print(sub.id)
teacher = ""
if sub.type == 1:
if not sub.teacher_old and not sub.teacher_new:
teacher = ""
elif sub.type == 1:
teacher = "<s>{}</s>".format(sub.teacher_old.shortcode if not full else sub.teacher_old.name)
elif sub.teacher_new and sub.teacher_old:
......
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