From 3808df22596ff03e8b24c9b97506f68c86197c60 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Fri, 6 Mar 2020 11:41:54 +0100 Subject: Sheet actions: add duplicate for site, operation, document and context record --- archaeological_context_records/models.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'archaeological_context_records/models.py') diff --git a/archaeological_context_records/models.py b/archaeological_context_records/models.py index febc7cfdd..9b1483e0d 100644 --- a/archaeological_context_records/models.py +++ b/archaeological_context_records/models.py @@ -459,7 +459,11 @@ class ContextRecord(BulkUpdatedItem, DocumentItem, BaseHistorizedItem, rights=['change_contextrecord', 'change_own_contextrecord'] ) QUICK_ACTIONS = [ - QA_LOCK + QA_LOCK, + QuickAction( + url="contextrecord-qa-duplicate", icon_class="fa fa-clone", + text=_(u"Duplicate"), target="one", + rights=['change_contextrecord', 'change_own_contextrecord']), ] history = HistoricalRecords(bases=[HistoryModel]) @@ -723,6 +727,19 @@ class ContextRecord(BulkUpdatedItem, DocumentItem, BaseHistorizedItem, def show_url(self): return reverse('show-contextrecord', args=[self.pk, '']) + def get_extra_actions(self, request): + # url, base_text, icon, extra_text, extra css class, is a quick action + actions = super(ContextRecord, self).get_extra_actions(request) + + #is_locked = hasattr(self, "is_locked") and self.is_locked(request.user) + can_edit_cr = self.can_do(request, 'change_contextrecord') + if can_edit_cr: + actions += [ + (reverse("contextrecord-qa-duplicate", args=[self.pk]), + _("Duplicate"), "fa fa-clone", "", "", True), + ] + return actions + @classmethod def get_query_owns(cls, ishtaruser): q = cls._construct_query_own( -- cgit v1.2.3