From edac69403fbf76ce709ddd530cd1af183c88f705 Mon Sep 17 00:00:00 2001
From: Dominik George <nik@naturalnet.de>
Date: Sat, 7 Sep 2019 16:11:33 +0200
Subject: [PATCH] Dimplify database constraint.

---
 biscuit/apps/chronos/models.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/biscuit/apps/chronos/models.py b/biscuit/apps/chronos/models.py
index b6ec3a08..9a5d5290 100644
--- a/biscuit/apps/chronos/models.py
+++ b/biscuit/apps/chronos/models.py
@@ -133,7 +133,7 @@ class LessonSubstitution(SchoolRelated):
                     'lesson_period__period__weekday', 'lesson_period__period__period']
         constraints = [
             models.CheckConstraint(
-                check=Q(cancelled=False, subject__isnull=False) | Q(cancelled=True, subject__isnull=True, room__isnull=True),
+                check=~Q(cancelled=True, subject__isnull=False),
                 name='either_substituted_or_cancelled'
             )
         ]
-- 
GitLab