From 924407531d8dbd3afb9c7044e29fdb2950253650 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Alexa=20Valentov=C3=A1?= <git@imaniti.org>
Date: Mon, 28 Apr 2025 14:44:56 +0200
Subject: [PATCH] update permissions

---
 contracts/forms.py | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/contracts/forms.py b/contracts/forms.py
index 350a9ba..bb3f457 100644
--- a/contracts/forms.py
+++ b/contracts/forms.py
@@ -87,6 +87,21 @@ class ContractAdminForm(forms.ModelForm):
                         )
 
                     continue
+            
+                # Allow people with approve permissions to mark contracts as TO_BE_APPROVED
+                if (
+                    self.instance.status == Contract.StatusTypes.WORK_IN_PROGRESS
+                    and choice_key == Contract.StatusTypes.TO_BE_APPROVED
+                    and self.current_user.has_perm("contracts.approve")
+                ):
+                    allowed_choices.append(
+                        (
+                            choice_key,
+                            choice_label,
+                        )
+                    )
+
+                    continue
 
                 if self.instance.status == choice_key:
                     allowed_choices.append(
-- 
GitLab