summaryrefslogtreecommitdiff
path: root/archaeological_context_records/models.py
diff options
context:
space:
mode:
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