diff --git a/biscuit/apps/untis/parse.py b/biscuit/apps/untis/parse.py index 594e5b5515cf8bfec81e59e39c028a52eb29e2b1..76147f2445b56ea7da7ef43a2aa11a8526114fe5 100755 --- a/biscuit/apps/untis/parse.py +++ b/biscuit/apps/untis/parse.py @@ -123,16 +123,18 @@ def build_drive(): "teachers": get_all_teachers(), "rooms": get_all_rooms(), "classes": get_all_classes(), - "subjects": get_all_subjects() + "subjects": get_all_subjects(), + "corridors": get_all_corridors(), } drive = { - "teachers": {}, - "rooms": {}, - "classes": {}, - "subjects": {} + # "teachers": {}, + # "rooms": {}, + # "classes": {}, + # "subjects": {} } for key, value in odrive.items(): + drive[key] = {} for el in value: id = el.id drive[key][id] = el diff --git a/biscuit/apps/untis/sub.py b/biscuit/apps/untis/sub.py index 396b5e941429749b38a262a72cf743412aeb6f20..3053a2ba027f07a43a660aaca688655f54314a3c 100644 --- a/biscuit/apps/untis/sub.py +++ b/biscuit/apps/untis/sub.py @@ -4,7 +4,7 @@ from untisconnect import models from untisconnect.api import run_default_filter, row_by_row_helper, get_teacher_by_id, get_subject_by_id, \ get_room_by_id, get_class_by_id, get_corridor_by_id from untisconnect.api_helper import run_using, untis_split_first -from untisconnect.parse import get_lesson_by_id, get_lesson_element_by_id_and_teacher +from untisconnect.parse import get_lesson_by_id, get_lesson_element_by_id_and_teacher, build_drive DATE_FORMAT = "%Y%m%d" @@ -32,6 +32,9 @@ def parse_type_of_untis_flags(flags): return type_ +drive = build_drive() + + class Substitution(object): def __init__(self): self.filled = False @@ -71,9 +74,9 @@ class Substitution(object): # Teacher # print(db_obj.teacher_idlessn) if db_obj.teacher_idlessn != 0: - self.teacher_old = get_teacher_by_id(db_obj.teacher_idlessn) + self.teacher_old = drive["teachers"][db_obj.teacher_idlessn] if db_obj.teacher_idsubst != 0: - self.teacher_new = get_teacher_by_id(db_obj.teacher_idsubst) + self.teacher_new = drive["teachers"][db_obj.teacher_idsubst] if self.teacher_old is not None and self.teacher_new.id == self.teacher_old.id: self.teacher_new = None @@ -84,7 +87,7 @@ class Substitution(object): # Subject self.subject_old = self.lesson_element.subject if self.lesson_element is not None else None if db_obj.subject_idsubst != 0: - self.subject_new = get_subject_by_id(db_obj.subject_idsubst) + self.subject_new = drive["subjects"][db_obj.subject_idsubst] if self.subject_old is not None and self.subject_old.id == self.subject_new.id: self.subject_new = None @@ -95,7 +98,7 @@ class Substitution(object): self.room_old = self.rooms_old[0] if db_obj.room_idsubst != 0: - self.room_new = get_room_by_id(db_obj.room_idsubst) + self.room_new = drive["rooms"][db_obj.room_idsubst] if self.room_old is not None and self.room_old.id == self.room_new.id: self.room_new = None @@ -105,7 +108,7 @@ class Substitution(object): # print("CORRIDOR") # print(self.corridor) if db_obj.corridor_id != 0: - self.corridor = get_corridor_by_id(db_obj.corridor_id) + self.corridor = drive["corridors"][db_obj.corridor_id] self.type = TYPE_CORRIDOR # Classes @@ -113,7 +116,7 @@ class Substitution(object): class_ids = untis_split_first(db_obj.classids, conv=int) # print(class_ids) for id in class_ids: - self.classes.append(get_class_by_id(id)) + self.classes.append(drive["classes"][id]) def substitutions_sorter(sub):