diff options
| author | Étienne Loks <etienne.loks@iggdrasil.net> | 2018-04-22 13:00:00 +0200 |
|---|---|---|
| committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2018-06-12 08:43:31 +0200 |
| commit | abd0cb791ab4e0ca35136c65ae3ec6def1539f15 (patch) | |
| tree | 5f69cd7f4c04c032bc8c4e49664c485bf80f65d4 /archaeological_finds/models_finds.py | |
| parent | 3a1fe3e257a5e8053ed961d3b6ba21d956ba842b (diff) | |
| download | Ishtar-abd0cb791ab4e0ca35136c65ae3ec6def1539f15.tar.bz2 Ishtar-abd0cb791ab4e0ca35136c65ae3ec6def1539f15.zip | |
Manage own permissions with areas for finds (refs #4060)
Diffstat (limited to 'archaeological_finds/models_finds.py')
| -rw-r--r-- | archaeological_finds/models_finds.py | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/archaeological_finds/models_finds.py b/archaeological_finds/models_finds.py index 35dc6995a..7155f3906 100644 --- a/archaeological_finds/models_finds.py +++ b/archaeological_finds/models_finds.py @@ -1094,14 +1094,21 @@ class Find(BulkUpdatedItem, ValueGetter, BaseHistorizedItem, ImageModel, @classmethod def get_query_owns(cls, ishtaruser): - return (Q(base_finds__context_record__operation__scientist= - ishtaruser.person) | - Q(base_finds__context_record__operation__in_charge= - ishtaruser.person) | - Q(base_finds__context_record__operation__collaborators__pk= - ishtaruser.person.pk) | - Q(history_creator=ishtaruser.user_ptr)) \ - & Q(base_finds__context_record__operation__end_date__isnull=True) + profile = ishtaruser.current_profile + town_ids = [] + if profile: + town_ids = [town['pk'] + for town in profile.query_towns.values('pk').all()] + return ( + Q(base_finds__context_record__operation__scientist= + ishtaruser.person) | + Q(base_finds__context_record__operation__in_charge= + ishtaruser.person) | + Q(base_finds__context_record__operation__collaborators__pk= + ishtaruser.person.pk) | + Q(history_creator=ishtaruser.user_ptr) | + Q(base_finds__context_record__operation__towns__pk__in=town_ids) + ) & Q(base_finds__context_record__operation__end_date__isnull=True) @classmethod def get_owns(cls, user, menu_filtr=None, limit=None, |
