summaryrefslogtreecommitdiff
path: root/archaeological_operations/models.py
diff options
context:
space:
mode:
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
commitaf93e3c6feb98bb6beabf258ba6d778208965766 (patch)
tree8c2acb06ee1489ce4507591a6b8c5a19cbad2eca /archaeological_operations/models.py
parent331ad0aed5fdae862259c513193ca34ed63c55c2 (diff)
downloadIshtar-af93e3c6feb98bb6beabf258ba6d778208965766.tar.bz2
Ishtar-af93e3c6feb98bb6beabf258ba6d778208965766.zip
Sites: fix permissions for collaborators
Diffstat (limited to 'archaeological_operations/models.py')
-rw-r--r--archaeological_operations/models.py22
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