From 0d11f15b794fddee459a8f6c9741430965e87256 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Valenta?= <tomas@imaniti.org> Date: Wed, 28 Feb 2024 15:47:16 +0100 Subject: [PATCH] fix permisions reading --- contracts/admin.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/contracts/admin.py b/contracts/admin.py index eea3864..ee23c5d 100644 --- a/contracts/admin.py +++ b/contracts/admin.py @@ -122,11 +122,14 @@ class ContractFileAdmin( class ParentContractInlineMixin: + def get_parent_object_is_editable(self, obj): + return obj.is_editable_without_approve_permission + def has_add_permission(self, request, obj=None): if ( obj is not None and not request.user.has_perm("contracts.edit_when_approved") - and not obj.is_editable_without_approve_permission + and not self.get_parent_object_is_editable() ): return False @@ -153,6 +156,9 @@ class ContracteeSignatureRepresentativeInline( extra = 1 formset = SingnatureRepresentativeFormSet + def get_parent_object_is_editable(self, obj): + return obj.contract.is_editable_without_approve_permission + def get_formset(self, request, obj=None, **kwargs): formset = super().get_formset(request, obj, **kwargs) formset.request = request @@ -170,6 +176,9 @@ class ContracteeSignatureInline(ParentContractInlineMixin, NestedStackedInline): class SigneeSignatureRepresentativeInline( ParentContractInlineMixin, NestedStackedInline ): + def get_parent_object_is_editable(self, obj): + return obj.contract.is_editable_without_approve_permission + model = SigneeSignatureRepresentative extra = 0 -- GitLab