diff --git a/biscuit/apps/untis/api.py b/biscuit/apps/untis/api.py index 9460d6e75c950e4106ba3e1b5b6e486b2be5c269..598b00ffcad34eba66707d1acd1c193d114ea13c 100755 --- a/biscuit/apps/untis/api.py +++ b/biscuit/apps/untis/api.py @@ -158,6 +158,38 @@ def get_room_by_id(id): return one_by_id(room, Room) +######## +# CORRIDOR # +######## +class Corridor(object): + def __init__(self): + self.filled = False + self.id = None + self.name = None + + def __str__(self): + if self.filled: + return self.name or "Unbekannt" + else: + return "Unbekannt" + + def create(self, db_obj): + self.filled = True + self.id = db_obj.corridor_id + self.name = db_obj.name + + +def get_all_corridors(): + corridors = row_by_row(models.Corridor, Corridor, filter_term=False) + return corridors + + +def get_corridor_by_id(id): + print(id) + corridor = run_one(models.Corridor.objects, filter_term=False).get(corridor_id=id) + return one_by_id(corridor, Corridor) + + ########### # SUBJECT # ########### diff --git a/biscuit/apps/untis/sub.py b/biscuit/apps/untis/sub.py index 8b1efef428b2c8bde67fab6b9513be00da797850..60df9ae636965ebe914af8be966374fb8e37086f 100644 --- a/biscuit/apps/untis/sub.py +++ b/biscuit/apps/untis/sub.py @@ -2,7 +2,7 @@ from django.utils import timezone 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_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 @@ -20,7 +20,7 @@ def date_to_untis_date(date): TYPE_SUBSTITUTION = 0 TYPE_CANCELLATION = 1 TYPE_TEACHER_CANCELLATION = 2 - +TYPE_CORRIDOR = 3 def parse_type_of_untis_flags(flags): type_ = TYPE_SUBSTITUTION @@ -100,9 +100,12 @@ class Substitution(object): self.room_new = None # if self.rooms_old - print(self.room_new) - self.corridor = db_obj.corridor_id - + # print(self.room_new) + # print("CORRIDOR") + # print(self.corridor) + if db_obj.corridor_id != 0: + self.corridor = get_corridor_by_id(db_obj.corridor_id) + self.type = TYPE_CORRIDOR # Classes self.classes = []