From 0aa8b2a19f264da6f0cef1953cd5f58293d6c17f Mon Sep 17 00:00:00 2001
From: Piotr Gawron <piotr.gawron@uni.lu>
Date: Thu, 16 Apr 2020 15:20:46 +0200
Subject: [PATCH] catch exception that could happen during migration

---
 smash/web/views/kit.py | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/smash/web/views/kit.py b/smash/web/views/kit.py
index d41cd8bd..374285be 100644
--- a/smash/web/views/kit.py
+++ b/smash/web/views/kit.py
@@ -235,12 +235,16 @@ def kit_requests_send_mail(request, start_date, end_date=None):
 
 class KitRequestEmailSendJob(CronJobBase):
     RUN_AT = []
-    times = ConfigurationItem.objects.get(
-        type=KIT_EMAIL_HOUR_CONFIGURATION_TYPE).value.split(";")
-    for entry in times:
-        # TODO it's a hack assuming that we are in CEST
-        text = str((int(entry.split(":")[0]) + 22) % 24) + ":" + entry.split(":")[1]
-        RUN_AT.append(text)
+
+    try:
+        times = ConfigurationItem.objects.get(
+            type=KIT_EMAIL_HOUR_CONFIGURATION_TYPE).value.split(";")
+        for entry in times:
+            # TODO it's a hack assuming that we are in CEST
+            text = str((int(entry.split(":")[0]) + 22) % 24) + ":" + entry.split(":")[1]
+            RUN_AT.append(text)
+    except:
+        logger.error("Cannot fetch data about email hour")
     schedule = Schedule(run_at_times=RUN_AT)
     code = 'web.kit_request_weekly_email'  # a unique code
 
-- 
GitLab