From 18097087e27173af3ba68e69c9a2b6350a687b72 Mon Sep 17 00:00:00 2001
From: "robinwilliam.hundt" <robinwilliam.hundt@stud.uni-goettingen.de>
Date: Thu, 18 Apr 2019 15:07:12 +0200
Subject: [PATCH] Small change to importer script, warns if submission type is
 changed

---
 util/importer.py | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/util/importer.py b/util/importer.py
index 8e02b438..8a6c4a37 100644
--- a/util/importer.py
+++ b/util/importer.py
@@ -1,6 +1,7 @@
 import json
 import os
 import readline
+import logging
 
 from util.messages import warn
 from core.models import ExamType, Feedback, Submission, SubmissionType, Test
@@ -9,6 +10,8 @@ from util.factories import GradyUserFactory
 
 import semver
 
+log = logging.getLogger(__name__)
+
 
 WELCOME = r'''
    ______               __         ____                           __
@@ -125,7 +128,10 @@ def load_hektor_json():
     exam, _ = ExamType.objects.get_or_create(**exam_data['module'])
 
     for submission_type in exam_data['submission_types']:
-        SubmissionType.objects.get_or_create(**submission_type)
+        _, created = SubmissionType.objects.update_or_create(
+            name=submission_type['name'], defaults=submission_type)
+        if not created:
+            log.warning(f"Updated submission type {submission_type}")
 
     for student in exam_data['students']:
         student_obj = user_factory.make_student(exam=exam,
-- 
GitLab