From 110775cd3aa93f0e7cd51b9d64888387bebf8e94 Mon Sep 17 00:00:00 2001
From: Jonathan Weth <git@jonathanweth.de>
Date: Mon, 27 Apr 2020 16:00:41 +0200
Subject: [PATCH] Rename abbrev to short_name

Close AlekSIS-App-Chronos#70
---
 aleksis/apps/untis/util/mysql/importers/common_data.py | 2 +-
 aleksis/apps/untis/util/mysql/importers/lessons.py     | 6 +++---
 aleksis/apps/untis/util/xml/xml.py                     | 8 ++++----
 3 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/aleksis/apps/untis/util/mysql/importers/common_data.py b/aleksis/apps/untis/util/mysql/importers/common_data.py
index 12d7a88..ddad586 100644
--- a/aleksis/apps/untis/util/mysql/importers/common_data.py
+++ b/aleksis/apps/untis/util/mysql/importers/common_data.py
@@ -53,7 +53,7 @@ def import_subjects() -> Dict[int, chronos_models.Subject]:
 
         # Get or create subject object by short name
         new_subject, created = chronos_models.Subject.objects.get_or_create(
-            abbrev=short_name,
+            short_name=short_name,
             defaults={
                 "name": name,
                 "colour_fg": colour_fg,
diff --git a/aleksis/apps/untis/util/mysql/importers/lessons.py b/aleksis/apps/untis/util/mysql/importers/lessons.py
index b9f79ab..d4afa14 100644
--- a/aleksis/apps/untis/util/mysql/importers/lessons.py
+++ b/aleksis/apps/untis/util/mysql/importers/lessons.py
@@ -118,7 +118,7 @@ def import_lessons(time_periods_ref, rooms_ref, subjects_ref, teachers_ref, clas
             if config.UNTIS_IMPORT_MYSQL_USE_COURSE_GROUPS:
                 # Negative import_ref denotes a course group
                 group_import_ref = -int("{}{}".format(lesson_id, i))
-                subject_ref = subject.abbrev
+                subject_ref = subject.short_name
 
                 # Search by parent groups and subject
                 qs = core_models.Group.objects.filter(
@@ -142,10 +142,10 @@ def import_lessons(time_periods_ref, rooms_ref, subjects_ref, teachers_ref, clas
 
                     # Build names and refs for course groups
                     group_short_name = "{}-{}".format(
-                        "".join([c.short_name for c in course_classes]), subject.abbrev
+                        "".join([c.short_name for c in course_classes]), subject.short_name
                     )
                     group_name = "{}: {}".format(
-                        ", ".join([c.short_name for c in course_classes]), subject.abbrev,
+                        ", ".join([c.short_name for c in course_classes]), subject.short_name
                     )
 
                     # Get or create course group
diff --git a/aleksis/apps/untis/util/xml/xml.py b/aleksis/apps/untis/util/xml/xml.py
index 4bc09e7..696f467 100644
--- a/aleksis/apps/untis/util/xml/xml.py
+++ b/aleksis/apps/untis/util/xml/xml.py
@@ -33,13 +33,13 @@ def untis_import_xml(request: HttpRequest, untis_xml: Union[BinaryIO, str]) -> N
 
     subjects = dom.getElementsByTagName("subject")
     for subject_node in subjects:
-        abbrev = subject_node.attributes["id"].value[3:]
+        short_name = subject_node.attributes["id"].value[3:]
         name = get_child_node_text(subject_node, "longname")
         colour_fg = get_child_node_text(subject_node, "forecolor")
         colour_bg = get_child_node_text(subject_node, "backcolor")
 
         Subject.objects.update_or_create(
-            abbrev=abbrev, defaults={"name": name, "colour_fg": colour_fg, "colour_bg": colour_bg},
+            short_name=short_name, defaults={"name": name, "colour_fg": colour_fg, "colour_bg": colour_bg},
         )
 
     periods = dom.getElementsByTagName("timeperiod")
@@ -92,7 +92,7 @@ def untis_import_xml(request: HttpRequest, untis_xml: Union[BinaryIO, str]) -> N
 
     lessons = dom.getElementsByTagName("lesson")
     for lesson_node in lessons:
-        subject_abbrev = get_child_node_id(lesson_node, "lesson_subject")[3:]
+        subject_short_name = get_child_node_id(lesson_node, "lesson_subject")[3:]
         teacher_short_name = get_child_node_id(lesson_node, "lesson_teacher")[3:]
         group_short_names = [
             v.strip()
@@ -113,7 +113,7 @@ def untis_import_xml(request: HttpRequest, untis_xml: Union[BinaryIO, str]) -> N
 
             time_periods.append((day, period, room))
 
-        subject = Subject.objects.get(abbrev=subject_abbrev)
+        subject = Subject.objects.get(short_name=subject_short_name)
         periods = [
             (
                 TimePeriod.objects.get(weekday=v[0], period=v[1]),
-- 
GitLab