From cdf5880fe4446edd058b04348792ee6af2bb2552 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Valenta?= <tomas@imaniti.org>
Date: Tue, 12 Mar 2024 14:34:28 +0100
Subject: [PATCH] fix crashing on validation errors

---
 contracts/admin.py | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/contracts/admin.py b/contracts/admin.py
index c1d1be4..d83bd23 100644
--- a/contracts/admin.py
+++ b/contracts/admin.py
@@ -159,9 +159,14 @@ class ContracteeSignatureRepresentativeInline(
     def get_parent_object_is_editable(self, obj):
         if hasattr(obj, "contract"):
             return obj.contract.is_editable_without_approve_permission
-        else:
+
+        # Crashes if there is invalid input otherwise.
+
+        elif hasattr(obj, "is_editable_without_approve_permission"):
             return obj.is_editable_without_approve_permission
 
+        return False
+
     def get_formset(self, request, obj=None, **kwargs):
         formset = super().get_formset(request, obj, **kwargs)
         formset.request = request
@@ -182,9 +187,14 @@ class SigneeSignatureRepresentativeInline(
     def get_parent_object_is_editable(self, obj):
         if hasattr(obj, "contract"):
             return obj.contract.is_editable_without_approve_permission
-        else:
+
+        # Crashes if there is invalid input otherwise.
+
+        elif hasattr(obj, "is_editable_without_approve_permission"):
             return obj.is_editable_without_approve_permission
 
+        return False
+
     model = SigneeSignatureRepresentative
     extra = 0
 
-- 
GitLab