diff options
Diffstat (limited to 'archaeological_operations')
-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 |