From 98d130ca45364b5caabf7074aa0cf17c7d140c2a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Valenta?= <git@imaniti.org>
Date: Thu, 8 Jun 2023 01:03:32 +0900
Subject: [PATCH] raise exception if person responsible for the paper form is
 missing

---
 contracts/models.py | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/contracts/models.py b/contracts/models.py
index 0179045..6e4a7a5 100644
--- a/contracts/models.py
+++ b/contracts/models.py
@@ -746,6 +746,22 @@ class Contract(NameStrMixin, models.Model):
                 }
             )
 
+        if (
+            self.paper_form_state not in (
+                self.PaperFormStates.STORED,
+                self.PaperFormStates.SHREDDED,
+                self.PaperFormStates.LOST
+            )
+            and not self.paper_form_person_responsible
+        ):
+            raise ValidationError(
+                {
+                    "paper_form_person_responsible": (
+                        "Musí být vyplněno, pokud smlouva není uložená / skartovaná / ztracená."
+                    )
+                }
+            )
+
         if (
             self.valid_start_date
             and self.valid_end_date
-- 
GitLab