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

Bug fix for absences (not only for teachers possible)

parent f4e61e9f
No related branches found
No related tags found
No related merge requests found
......@@ -4,6 +4,10 @@ from untisconnect.api_helper import get_term_by_id, run_using, untis_date_to_dat
from . import models
from timetable.settings import untis_settings
TYPE_TEACHER = 0
TYPE_ROOM = 1
TYPE_CLASS = 2
def run_all(obj, filter_term=True):
return run_default_filter(run_using(obj).all(), filter_term=filter_term)
......@@ -276,6 +280,8 @@ class Absence(object):
def __init__(self):
self.filled = None
self.teacher = None
self.room = None
self.type = TYPE_TEACHER
self.from_date = None
self.to_date = None
self.from_lesson = None
......@@ -284,8 +290,14 @@ class Absence(object):
def create(self, db_obj):
self.filled = True
print(db_obj.ida)
self.teacher = get_teacher_by_id(db_obj.ida)
# print(db_obj.ida)
print(db_obj.typea)
self.type = TYPE_TEACHER if db_obj.typea != 102 else TYPE_ROOM
if self.type == TYPE_TEACHER:
self.teacher = get_teacher_by_id(db_obj.ida)
else:
self.room = get_room_by_id(db_obj.ida)
self.from_date = untis_date_to_date(db_obj.datefrom)
self.to_date = untis_date_to_date(db_obj.dateto)
self.from_lesson = db_obj.lessonfrom
......
......@@ -4,14 +4,10 @@ from django.utils import timezone
from schoolapps import settings
from schoolapps.settings import LESSONS
from untisconnect.api import format_classes
from untisconnect.api import format_classes, TYPE_CLASS, TYPE_TEACHER, TYPE_ROOM
from untisconnect.parse import parse
from untisconnect.sub import get_substitutions_by_date_as_dict, TYPE_CANCELLATION
TYPE_TEACHER = 0
TYPE_ROOM = 1
TYPE_CLASS = 2
class LessonContainer(object):
"""
......
from django.utils import timezone
from untisconnect import models
from untisconnect.api import run_default_filter, row_by_row_helper, format_classes, get_all_absences_by_date
from untisconnect.api import run_default_filter, row_by_row_helper, format_classes, get_all_absences_by_date, \
TYPE_TEACHER
from untisconnect.api_helper import run_using, untis_split_first, untis_date_to_date, date_to_untis_date
from untisconnect.parse import get_lesson_element_by_id_and_teacher
from untisconnect.drive import build_drive
......@@ -83,7 +84,7 @@ class Substitution(object):
self.teacher_old = self.teacher_new
self.teacher_new = None
print(self.teacher_old, self.teacher_new)
# 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)
......@@ -275,6 +276,8 @@ def get_header_information(subs, date):
if info.absences:
elements = []
for absence in info.absences:
if absence.type != TYPE_TEACHER:
continue
if absence.is_whole_day:
# Teacher is missing the whole day
elements.append("{}".format(absence.teacher.shortcode))
......
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