diff options
Diffstat (limited to 'archaeological_context_records/models.py')
-rw-r--r-- | archaeological_context_records/models.py | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/archaeological_context_records/models.py b/archaeological_context_records/models.py index febc7cfdd..02b074706 100644 --- a/archaeological_context_records/models.py +++ b/archaeological_context_records/models.py @@ -362,6 +362,11 @@ class ContextRecord(BulkUpdatedItem, DocumentItem, BaseHistorizedItem, 'operation_id': 'operation_id', 'unit__label': "unit__label" } + REVERSED_BOOL_FIELDS = [ + 'documents__image__isnull', + 'documents__associated_file__isnull', + 'documents__associated_url__isnull', + ] RELATION_TYPES_PREFIX = {'ope_relation_types': 'operation__', 'cr_relation_types': ''} # alternative names of fields for searches @@ -416,6 +421,7 @@ class ContextRecord(BulkUpdatedItem, DocumentItem, BaseHistorizedItem, ), } ALT_NAMES.update(BaseHistorizedItem.ALT_NAMES) + ALT_NAMES.update(DocumentItem.ALT_NAMES) PARENT_ONLY_SEARCH_VECTORS = ["operation", "archaeological_site", "parcel"] BASE_SEARCH_VECTORS = [ @@ -459,7 +465,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 +733,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( |