From e888f941c0ffd00abc74f78096084cdcddb73c82 Mon Sep 17 00:00:00 2001
From: Jonathan Weth <git@jonathanweth.de>
Date: Wed, 2 Dec 2020 17:30:58 +0100
Subject: [PATCH] Import supervisions with a link to a validity range

---
 aleksis/apps/untis/util/mysql/importers/common_data.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/aleksis/apps/untis/util/mysql/importers/common_data.py b/aleksis/apps/untis/util/mysql/importers/common_data.py
index 791d02a..2627b6a 100644
--- a/aleksis/apps/untis/util/mysql/importers/common_data.py
+++ b/aleksis/apps/untis/util/mysql/importers/common_data.py
@@ -370,6 +370,7 @@ def import_supervision_areas(
 
                 # Get or create
                 new_supervision, created = new_area.supervisions.get_or_create(
+                    validity=validity_range,
                     break_item=breaks_ref[weekday][period_after_break],
                     defaults={"teacher": teacher},
                 )
@@ -385,7 +386,7 @@ def import_supervision_areas(
                     supervisions_ref[weekday][period_after_break] = []
                 supervisions_ref[weekday][period_after_break].append(new_supervision)
 
-        for supervision in new_area.supervisions.all():
+        for supervision in new_area.supervisions.filter(validity=validity_range):
             delete = True
 
             # Get weekday and period after break
-- 
GitLab