diff options
Diffstat (limited to 'archaeological_operations/models.py')
| -rw-r--r-- | archaeological_operations/models.py | 61 | 
1 files changed, 46 insertions, 15 deletions
diff --git a/archaeological_operations/models.py b/archaeological_operations/models.py index 9119a5c72..a074adc9a 100644 --- a/archaeological_operations/models.py +++ b/archaeological_operations/models.py @@ -31,7 +31,7 @@ from django.contrib.gis.db.models.functions import Centroid  from django.contrib.postgres.indexes import GinIndex  from django.contrib.sites.models import Site  from django.db import transaction, OperationalError, IntegrityError -from django.db.models import Q, Count, Sum, Max, Avg +from django.db.models import Q, Max  from django.db.models.signals import post_save, m2m_changed, post_delete  from django.forms import ValidationError  from django.urls import reverse @@ -579,14 +579,20 @@ class ArchaeologicalSite(          icon_class="fa fa-lock",          text=_("Lock/Unlock"),          target="many", -        rights=["change_archaeologicalsite", "change_own_archaeologicalsite"], +        rights=[ +            "archaeological_operations.change_archaeologicalsite", +            "archaeological_operations.change_own_archaeologicalsite" +        ],      )      QA_EDIT = QuickAction(          url="site-qa-bulk-update",          icon_class="fa fa-pencil",          text=_("Bulk update"),          target="many", -        rights=["change_archaeologicalsite", "change_own_archaeologicalsite"], +        rights=[ +            "archaeological_operations.change_archaeologicalsite", +            "archaeological_operations.change_own_archaeologicalsite" +        ],      )      QUICK_ACTIONS = [          QA_EDIT, @@ -596,7 +602,7 @@ class ArchaeologicalSite(              icon_class="fa fa-plus",              text=_("Create associated operation"),              target="many", -            rights=["change_operation"], +            rights=["archaeological_operations.add_operation"],              is_popup=False          ),          QuickAction( @@ -604,7 +610,10 @@ class ArchaeologicalSite(              icon_class="fa fa-clone",              text=_("Duplicate"),              target="one", -            rights=["change_archaeologicalsite", "change_own_archaeologicalsite"], +            rights=[ +                "archaeological_operations.change_archaeologicalsite", +                "archaeological_operations.change_own_archaeologicalsite" +            ],          ),      ] @@ -780,8 +789,12 @@ class ArchaeologicalSite(          actions = super(ArchaeologicalSite, self).get_extra_actions(request)          is_locked = self.is_locked(request.user)          profile = get_current_profile() -        can_edit_site = self.can_do(request, "change_archaeologicalsite") -        can_add_geo = profile.mapping and self.can_do(request, "add_geovectordata") +        can_edit_site = self.can_do( +            request, "archaeological_operations.change_archaeologicalsite" +        ) +        can_add_geo = profile.mapping and self.can_do( +            request, "ishtar_common.add_geovectordata" +        )          if can_add_geo:              actions.append(self.get_add_geo_action()) @@ -797,7 +810,9 @@ class ArchaeologicalSite(                  ),              ] -        can_create_operation = self.can_do(request, "change_operation") +        can_create_operation = self.can_do( +            request, "archaeological_operations.change_operation" +        )          if can_create_operation and not self.operations.count():              actions.append(                  ( @@ -1439,14 +1454,20 @@ class Operation(          icon_class="fa fa-pencil",          text=_("Bulk update"),          target="many", -        rights=["change_operation", "change_own_operation"], +        rights=[ +            "archaeological_operations.change_operation", +            "archaeological_operations.change_own_operation" +        ],      )      QA_LOCK = QuickAction(          url="operation-qa-lock",          icon_class="fa fa-lock",          text=_("Lock/Unlock"),          target="many", -        rights=["change_operation", "change_own_operation"], +        rights=[ +            "archaeological_operations.change_operation", +            "archaeological_operations.change_own_operation" +        ],      )      QUICK_ACTIONS = [          QA_EDIT, @@ -1456,7 +1477,10 @@ class Operation(              icon_class="fa fa-clone",              text=_("Duplicate"),              target="one", -            rights=["change_operation", "change_own_operation"], +            rights=[ +                "archaeological_operations.change_operation", +                "archaeological_operations.change_own_operation" +            ],          ),      ] @@ -2124,7 +2148,9 @@ class Operation(          actions = super(Operation, self).get_extra_actions(request)          is_locked = self.is_locked(request.user) -        can_edit_operation = self.can_do(request, "change_operation") +        can_edit_operation = self.can_do( +                request, "archaeological_operations.change_operation" +        )          if can_edit_operation and not is_locked:              actions = [                  ( @@ -2138,10 +2164,14 @@ class Operation(              ] + actions          profile = get_current_profile() -        can_add_geo = profile.mapping and self.can_do(request, "add_geovectordata") +        can_add_geo = profile.mapping and self.can_do( +            request, "ishtar_common.add_geovectordata" +        )          if can_add_geo:              actions.append(self.get_add_geo_action()) -        can_add_cr = self.can_do(request, "add_contextrecord") +        can_add_cr = self.can_do( +            request, "archaeological_context_records.add_contextrecord" +        )          if can_add_cr and not is_locked:              start = actions              end = [] @@ -2158,7 +2188,8 @@ class Operation(                      True,                  ),              ] + end -        if profile.files and self.can_do(request, "add_administrativeact"): +        if profile.files and self.can_do( +                request, "archaeological_operations.add_administrativeact"):              actions += [                  (                      reverse("operation-add-adminact", args=[self.pk]),  | 
