diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2020-03-06 11:41:54 +0100 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2020-03-06 11:44:44 +0100 |
commit | 3808df22596ff03e8b24c9b97506f68c86197c60 (patch) | |
tree | 87dc15b6b07b78eb8aed52a707c9adab5ae89a9f /archaeological_operations/models.py | |
parent | 2ebb25f9a93d9b840162ca035c243354a3169a87 (diff) | |
download | Ishtar-3808df22596ff03e8b24c9b97506f68c86197c60.tar.bz2 Ishtar-3808df22596ff03e8b24c9b97506f68c86197c60.zip |
Sheet actions: add duplicate for site, operation, document and context record
Diffstat (limited to 'archaeological_operations/models.py')
-rw-r--r-- | archaeological_operations/models.py | 38 |
1 files changed, 35 insertions, 3 deletions
diff --git a/archaeological_operations/models.py b/archaeological_operations/models.py index 402f45485..54a44999c 100644 --- a/archaeological_operations/models.py +++ b/archaeological_operations/models.py @@ -283,7 +283,12 @@ class ArchaeologicalSite(DocumentItem, BaseHistorizedItem, QRCodeItem, rights=['change_operation', 'change_own_operation'] ) QUICK_ACTIONS = [ - QA_LOCK + QA_LOCK, + QuickAction( + url="site-qa-duplicate", icon_class="fa fa-clone", + text=_("Duplicate"), target="one", + rights=['change_archaeologicalsite', + 'change_own_archaeologicalsite']), ] objects = SiteManager() @@ -409,6 +414,22 @@ class ArchaeologicalSite(DocumentItem, BaseHistorizedItem, QRCodeItem, return Find.objects.filter( base_finds__context_record__archaeological_site__pk=self.pk) + def get_extra_actions(self, request): + """ + 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) + + can_edit_site = self.can_do(request, 'change_archaeologicalsite') + if can_edit_site: + actions += [ + (reverse("site-qa-duplicate", args=[self.pk]), + _("Duplicate"), "fa fa-clone", "", "", True), + ] + return actions + @classmethod def _get_query_owns_dicts(cls, ishtaruser, no_rel=False): profile = ishtaruser.current_profile @@ -932,7 +953,11 @@ class Operation(ClosedItem, DocumentItem, BaseHistorizedItem, QRCodeItem, rights=['change_operation', 'change_own_operation'] ) QUICK_ACTIONS = [ - QA_EDIT, QA_LOCK + QA_EDIT, QA_LOCK, + QuickAction( + url="operation-qa-duplicate", icon_class="fa fa-clone", + text=_("Duplicate"), target="one", + rights=['change_operation', 'change_own_operation']), ] UP_MODEL_QUERY = { @@ -1352,9 +1377,16 @@ class Operation(ClosedItem, DocumentItem, BaseHistorizedItem, QRCodeItem, """ # url, base_text, icon, extra_text, extra css class, is a quick action actions = super(Operation, self).get_extra_actions(request) + is_locked = self.is_locked(request.user) + can_edit_operation = self.can_do(request, 'change_operation') + if can_edit_operation: + actions += [ + (reverse("operation-qa-duplicate", args=[self.pk]), + _("Duplicate"), "fa fa-clone", "", "", True), + ] can_add_cr = self.can_do(request, 'add_contextrecord') - if can_add_cr and not self.is_locked(request.user): + if can_add_cr and not is_locked: actions += [ (reverse('operation-qa-contextrecord', args=[self.pk]), _("Add context record"), "fa fa-plus", |