summaryrefslogtreecommitdiff
path: root/archaeological_operations/models.py
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2018-04-19 18:22:21 +0200
committerÉtienne Loks <etienne.loks@iggdrasil.net>2018-06-12 08:43:31 +0200
commit22db3f5104646251bc22bef1daa3dbe16c81c5ff (patch)
treebc1e1f4349a10489a489a5b52d515c196d20fda9 /archaeological_operations/models.py
parent56648473d068541fe4e0693ea277ea07527de4e9 (diff)
downloadIshtar-22db3f5104646251bc22bef1daa3dbe16c81c5ff.tar.bz2
Ishtar-22db3f5104646251bc22bef1daa3dbe16c81c5ff.zip
Manage own permissions with areas for operations
Diffstat (limited to 'archaeological_operations/models.py')
-rw-r--r--archaeological_operations/models.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/archaeological_operations/models.py b/archaeological_operations/models.py
index c342fb2a4..9655ca387 100644
--- a/archaeological_operations/models.py
+++ b/archaeological_operations/models.py
@@ -698,11 +698,18 @@ class Operation(ClosedItem, BaseHistorizedItem, ImageModel, OwnPerms,
@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(in_charge=ishtaruser.person) |
Q(scientist=ishtaruser.person) |
Q(collaborators__pk=ishtaruser.person.pk) |
- Q(history_creator=ishtaruser.user_ptr)) & Q(end_date__isnull=True)
+ Q(history_creator=ishtaruser.user_ptr) |
+ Q(towns__pk__in=town_ids)
+ ) & Q(end_date__isnull=True)
def is_active(self):
return not bool(self.end_date)