diff options
| author | Étienne Loks <etienne.loks@iggdrasil.net> | 2019-10-28 17:24:21 +0100 | 
|---|---|---|
| committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2019-10-28 17:24:21 +0100 | 
| commit | 8977a1f316da54e81344035e9e2d7aaa8f49b9f9 (patch) | |
| tree | 8c2acb06ee1489ce4507591a6b8c5a19cbad2eca /archaeological_operations/models.py | |
| parent | c3f12bbd494db0873cda87495d0f61fb01404d42 (diff) | |
| download | Ishtar-8977a1f316da54e81344035e9e2d7aaa8f49b9f9.tar.bz2 Ishtar-8977a1f316da54e81344035e9e2d7aaa8f49b9f9.zip  | |
Sites: fix permissions for collaborators
Diffstat (limited to 'archaeological_operations/models.py')
| -rw-r--r-- | archaeological_operations/models.py | 22 | 
1 files changed, 19 insertions, 3 deletions
diff --git a/archaeological_operations/models.py b/archaeological_operations/models.py index c295e40ac..900779643 100644 --- a/archaeological_operations/models.py +++ b/archaeological_operations/models.py @@ -399,6 +399,22 @@ class ArchaeologicalSite(DocumentItem, BaseHistorizedItem, QRCodeItem,              base_finds__context_record__archaeological_site__pk=self.pk)      @classmethod +    def _get_query_owns_dicts(cls, ishtaruser, no_rel=False): +        profile = ishtaruser.current_profile +        town_ids = [] +        if profile: +            town_ids = [town['pk'] +                        for town in profile.query_towns.values('pk').all()] +        query_owns = [ +            { +                'collaborators__pk': ishtaruser.person.pk, +                'history_creator': ishtaruser.user_ptr, +                'towns__pk__in': town_ids, +            } +        ] +        return query_owns + +    @classmethod      def get_query_owns(cls, ishtaruser):          from archaeological_warehouse.models import Warehouse          q = cls._construct_query_own( @@ -421,9 +437,9 @@ class ArchaeologicalSite(DocumentItem, BaseHistorizedItem, QRCodeItem,                                                              no_rel=True)          ) | cls._construct_query_own(              'top_operations__', Operation._get_query_owns_dicts(ishtaruser) -        ) | cls._construct_query_own('', [ -            {'history_creator': ishtaruser.user_ptr} -        ]) +        ) | cls._construct_query_own( +            '', cls._get_query_owns_dicts(ishtaruser) +        )          return q      @classmethod  | 
