diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2024-10-10 13:42:18 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2024-10-14 16:48:37 +0200 |
commit | 435797a54e4d322a46711f303c2fc1fd5286330e (patch) | |
tree | 7c209135a17fe9b12fa2e2e844f345debed45d97 /archaeological_operations/models.py | |
parent | 69df0a88eeaafeee81d76a3307e79fe5cad8ecf8 (diff) | |
download | Ishtar-435797a54e4d322a46711f303c2fc1fd5286330e.tar.bz2 Ishtar-435797a54e4d322a46711f303c2fc1fd5286330e.zip |
✨ site and operation relations forms refactoring
Diffstat (limited to 'archaeological_operations/models.py')
-rw-r--r-- | archaeological_operations/models.py | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/archaeological_operations/models.py b/archaeological_operations/models.py index f8c8f20a0..63904bebe 100644 --- a/archaeological_operations/models.py +++ b/archaeological_operations/models.py @@ -759,18 +759,31 @@ class ArchaeologicalSite( base_finds__context_record__archaeological_site__pk=self.pk ) - def get_extra_actions(self, request): + def get_extra_actions(self, request, window_id=None): """ For sheet template """ # url, base_text, icon, extra_text, extra css class, is a quick action actions = super(ArchaeologicalSite, self).get_extra_actions(request) - # is_locked = self.is_locked(request.user) + 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") if can_add_geo: actions.append(self.get_add_geo_action()) + if can_edit_site and not is_locked: + actions += [ + ( + reverse("site-operation-relations-modify", args=[self.pk, window_id]), + _("Modify site-operation relations"), + "fa fa-retweet", + _("operations"), + "", + True, + ), + ] + can_create_operation = self.can_do(request, "change_operation") if can_create_operation and not self.operations.count(): actions.append( @@ -796,7 +809,6 @@ class ArchaeologicalSite( ) ) - can_edit_site = self.can_do(request, "change_archaeologicalsite") if can_edit_site: actions += [ ( @@ -2096,7 +2108,7 @@ class Operation( ).distinct("location", "index") return q - def get_extra_actions(self, request): + def get_extra_actions(self, request, window_id=None): """ For sheet template """ @@ -2160,6 +2172,16 @@ class Operation( True, ), ] + actions += [ + ( + reverse("operation-site-relations-modify", args=[self.pk, window_id]), + _("Modify operation-site relations"), + "fa fa-retweet", + profile.get_site_label("plural").lower(), + "", + True, + ), + ] if can_edit_operation: actions += [ |