diff options
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 |
commit | 9777cde256561c13eb3e80dbc07e693f162a7b28 (patch) | |
tree | 9c5cdc5f59b4b5e0507e76fac02dd1f765cfa0fe /archaeological_context_records/models.py | |
parent | 2368faf369dfb6c9cf896d54c2540dc933382cb7 (diff) | |
download | Ishtar-9777cde256561c13eb3e80dbc07e693f162a7b28.tar.bz2 Ishtar-9777cde256561c13eb3e80dbc07e693f162a7b28.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.py | 8 |
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 |