Newer
Older
from aleksis.apps.untis.util.mysql.importers.terms import import_terms, get_terms_for_date
from aleksis.apps.untis.util.mysql.util import TQDM_DEFAULTS

Nik | Klampfradler
committed
from django.db import transaction

Nik | Klampfradler
committed
from aleksis.apps.untis.util.mysql.importers.terms import (
get_terms_for_date,
import_terms,
)
from aleksis.apps.untis.util.mysql.util import TQDM_DEFAULTS
from .importers.absences import import_absences
import_time_periods,
from .importers.holidays import import_holidays
from .importers.lessons import import_lessons
from .importers.substitutions import import_substitutions

Nik | Klampfradler
committed
@transaction.atomic
def untis_import_mysql():
# School terms and validity ranges
terms = get_terms_for_date()
validity_ref = import_terms(terms)
for validity_range in tqdm(
validity_ref.values(), desc="Import data for terms", **TQDM_DEFAULTS
):
# Common data for Chronos
subjects_ref = import_subjects(validity_range)
rooms_ref = import_rooms(validity_range)
absence_reasons_ref = import_absence_reasons(validity_range)

Jonathan Weth
committed
# Common data for core
teachers_ref = import_teachers(validity_range)
classes_ref = import_classes(validity_range, teachers_ref)

Jonathan Weth
committed
# Time periods
time_periods_ref = import_time_periods(validity_range)
breaks_ref = import_breaks(validity_range, time_periods_ref)
# Holidays
holidays_ref = import_holidays(validity_range)
# Supervisions
supervision_areas_ref = import_supervision_areas(
validity_range, breaks_ref, teachers_ref
)

Jonathan Weth
committed
import_lessons(
validity_range,
time_periods_ref,
rooms_ref,
subjects_ref,
teachers_ref,
classes_ref,
)
# Substitutions
import_absences(
validity_range,
absence_reasons_ref,
time_periods_ref,
teachers_ref,
classes_ref,
rooms_ref,
)
import_substitutions(
validity_range,
teachers_ref,
subjects_ref,
rooms_ref,
classes_ref,
supervision_areas_ref,
time_periods_ref,
)
import_events(
validity_range, time_periods_ref, teachers_ref, classes_ref, rooms_ref
)