From cd17dd8715a846cccee3ada897b8774a9985f1ff Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Wed, 22 Feb 2023 13:35:49 +0100 Subject: File: filter plan action when preventive_operator is activated in profile --- archaeological_files/models.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'archaeological_files/models.py') diff --git a/archaeological_files/models.py b/archaeological_files/models.py index 529e3e0e6..d81433a25 100644 --- a/archaeological_files/models.py +++ b/archaeological_files/models.py @@ -29,7 +29,7 @@ from django.core.validators import MinValueValidator, MaxValueValidator from django.db.models import Q, Count, Sum, Max from django.db.models.signals import post_save, m2m_changed, post_delete from django.urls import reverse -from ishtar_common.utils import ugettext_lazy as _, pgettext_lazy +from ishtar_common.utils import ugettext_lazy as _, pgettext_lazy, get_current_profile from ishtar_common.utils import ( cached_label_changed, @@ -1241,7 +1241,8 @@ class File( True, ), ] - if self.can_do(request, "add_administrativeact"): + profile = get_current_profile() + if profile.preventive_operator: actions += [ ( reverse("file-edit-preventive", args=[self.pk]), @@ -1251,6 +1252,9 @@ class File( "", False, ), + ] + if self.can_do(request, "add_administrativeact"): + actions += [ ( reverse("file-add-adminact", args=[self.pk]), _("Add associated administrative act"), -- cgit v1.2.3