diff options
| -rw-r--r-- | archaeological_context_records/models.py | 9 | ||||
| -rw-r--r-- | archaeological_finds/models_finds.py | 12 | ||||
| -rw-r--r-- | archaeological_operations/models.py | 7 | ||||
| -rw-r--r-- | ishtar_common/models.py | 2 | 
4 files changed, 29 insertions, 1 deletions
| diff --git a/archaeological_context_records/models.py b/archaeological_context_records/models.py index bba9c643b..5e6b4622b 100644 --- a/archaeological_context_records/models.py +++ b/archaeological_context_records/models.py @@ -624,3 +624,12 @@ class ContextRecordSource(Source):      @property      def owner(self):          return self.context_record + +    @classmethod +    def get_query_owns(cls, user): +        return ( +            Q(context_record__operation__scientist=user.ishtaruser.person) | +            Q(context_record__operation__in_charge=user.ishtaruser.person) | +            Q(context_record__operation__collaborators__pk= +              user.ishtaruser.person.pk)) \ +               & Q(context_record__operation__end_date__isnull=True) diff --git a/archaeological_finds/models_finds.py b/archaeological_finds/models_finds.py index 735bc01a8..f6be69f93 100644 --- a/archaeological_finds/models_finds.py +++ b/archaeological_finds/models_finds.py @@ -1078,6 +1078,18 @@ class FindSource(Source):      def owner(self):          return self.find +    @classmethod +    def get_query_owns(cls, user): +        return (Q(find__base_finds__context_record__operation__scientist=user. +                  ishtaruser.person) | +                Q(find__base_finds__context_record__operation__in_charge=user. +                  ishtaruser.person) | +                Q( +            find__base_finds__context_record__operation__collaborators__pk=user. +            ishtaruser.person.pk)) \ +               & Q( +            find__base_finds__context_record__operation__end_date__isnull=True) +  class Property(LightHistorizedItem):      find = models.ForeignKey(Find, verbose_name=_(u"Find")) diff --git a/archaeological_operations/models.py b/archaeological_operations/models.py index 13997a632..d18181722 100644 --- a/archaeological_operations/models.py +++ b/archaeological_operations/models.py @@ -915,6 +915,13 @@ class OperationSource(Source):          return u"{}-{:04d}".format(self.operation.code_patriarche or '',                                     self.index) +    @classmethod +    def get_query_owns(cls, user): +        return (Q(operation__in_charge=user.ishtaruser.person) | +                Q(operation__scientist=user.ishtaruser.person) | +                Q(operation__collaborators__pk=user.ishtaruser.person.pk)) \ +               & Q(operation__end_date__isnull=True) +  class ActType(GeneralType):      TYPE = (('F', _(u'Archaeological file')), diff --git a/ishtar_common/models.py b/ishtar_common/models.py index 35608abdf..6a9f86569 100644 --- a/ishtar_common/models.py +++ b/ishtar_common/models.py @@ -2903,7 +2903,7 @@ post_save.connect(post_save_cache, sender=Format)  post_delete.connect(post_save_cache, sender=Format) -class Source(ImageModel, models.Model): +class Source(OwnPerms, ImageModel, models.Model):      title = models.CharField(_(u"Title"), max_length=300)      external_id = models.CharField(_(u"External ID"), max_length=12, null=True,                                     blank=True) | 
