diff options
Diffstat (limited to 'ishtar_common/models.py')
| -rw-r--r-- | ishtar_common/models.py | 44 | 
1 files changed, 33 insertions, 11 deletions
| diff --git a/ishtar_common/models.py b/ishtar_common/models.py index 3715c0326..bc0cb7b09 100644 --- a/ishtar_common/models.py +++ b/ishtar_common/models.py @@ -1216,9 +1216,34 @@ class DocumentItem(object):              return Document.objects.none()          return self.documents.filter(image__isnull=False).exclude(image="") +    def get_extra_actions(self, request): +        """ +        For sheet template: return "Add document / image" action +        """ +        # url, base_text, icon, extra_text, extra css class +        actions = [] +        can_add_doc = request.user.ishtaruser.has_right( +            'add_document', request.session) or ( +                request.user.ishtaruser.has_right( +                    'add_own_document', request.session) and +                self.is_own(request.user.ishtaruser) +        ) +        if can_add_doc: +            actions = [ +                ( +                    reverse("create-document") + "?{}={}".format(self.SLUG, +                                                                 self.pk), +                    _(u"Add document/image"), +                    "fa fa-plus", +                    _(u"doc./image"), +                    "" +                ) +            ] +        return actions + -class BaseHistorizedItem(FullSearch, Imported, JsonData, FixAssociated, -                         DocumentItem): +class BaseHistorizedItem(DocumentItem, FullSearch, Imported, JsonData, +                         FixAssociated):      """      Historized item with external ID management.      All historized items are searcheable and have a data json field @@ -2707,19 +2732,16 @@ class Person(Address, Merge, OwnPerms, ValueGetter):          return slugify(u"-".join(values))      def operation_docs_q(self): -        from archaeological_operations.models import OperationSource -        return OperationSource.objects.filter( -            authors__person=self) +        return Document.objects.filter( +            authors__person=self, operations__pk__isnull=False)      def contextrecord_docs_q(self): -        from archaeological_context_records.models import ContextRecordSource -        return ContextRecordSource.objects.filter( -            authors__person=self) +        return Document.objects.filter( +            authors__person=self, context_records__pk__isnull=False)      def find_docs_q(self): -        from archaeological_finds.models import FindSource -        return FindSource.objects.filter( -            authors__person=self) +        return Document.objects.filter( +            authors__person=self, finds__pk__isnull=False)      def save(self, *args, **kwargs):          super(Person, self).save(*args, **kwargs) | 
