summaryrefslogtreecommitdiff
path: root/archaeological_context_records/models.py
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2018-04-20 15:04:48 +0200
committerÉtienne Loks <etienne.loks@iggdrasil.net>2018-06-12 08:43:31 +0200
commit3a1fe3e257a5e8053ed961d3b6ba21d956ba842b (patch)
tree9c5cdc5f59b4b5e0507e76fac02dd1f765cfa0fe /archaeological_context_records/models.py
parentf11450c633fad24307df7924fd4d2e409a603573 (diff)
downloadIshtar-3a1fe3e257a5e8053ed961d3b6ba21d956ba842b.tar.bz2
Ishtar-3a1fe3e257a5e8053ed961d3b6ba21d956ba842b.zip
Manage own permissions with areas for context records (refs #4060)
Diffstat (limited to 'archaeological_context_records/models.py')
-rw-r--r--archaeological_context_records/models.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/archaeological_context_records/models.py b/archaeological_context_records/models.py
index 90c3d5563..996304231 100644
--- a/archaeological_context_records/models.py
+++ b/archaeological_context_records/models.py
@@ -429,10 +429,16 @@ class ContextRecord(BulkUpdatedItem, BaseHistorizedItem,
@classmethod
def get_query_owns(cls, ishtaruser):
+ profile = ishtaruser.current_profile
+ town_ids = []
+ if profile:
+ town_ids = [town['pk']
+ for town in profile.query_towns.values('pk').all()]
return (Q(operation__scientist=ishtaruser.person) |
Q(operation__in_charge=ishtaruser.person) |
Q(operation__collaborators__pk=ishtaruser.person.pk) |
- Q(history_creator=ishtaruser.user_ptr)) \
+ Q(history_creator=ishtaruser.user_ptr) |
+ Q(operation__towns__pk__in=town_ids)) \
& Q(operation__end_date__isnull=True)
@classmethod