diff options
-rw-r--r-- | archaeological_operations/models.py | 4 | ||||
-rw-r--r-- | ishtar_common/models.py | 12 |
2 files changed, 15 insertions, 1 deletions
diff --git a/archaeological_operations/models.py b/archaeological_operations/models.py index d18181722..bef149b2c 100644 --- a/archaeological_operations/models.py +++ b/archaeological_operations/models.py @@ -270,7 +270,9 @@ class Operation(ClosedItem, BaseHistorizedItem, ImageModel, OwnPerms, on_delete=models.SET_NULL, related_name='operation_responsability') collaborators = models.ManyToManyField( - Person, blank=True, null=True, verbose_name=_(u"Collaborators")) + Person, blank=True, null=True, verbose_name=_(u"Collaborators"), + related_name='operation_collaborator' + ) year = models.IntegerField(_(u"Year"), null=True, blank=True) operation_code = models.IntegerField(_(u"Numeric reference"), null=True, blank=True) diff --git a/ishtar_common/models.py b/ishtar_common/models.py index 048af1294..66433747c 100644 --- a/ishtar_common/models.py +++ b/ishtar_common/models.py @@ -2770,6 +2770,18 @@ class Person(Address, Merge, OwnPerms, ValueGetter): for fle in self.general_contractor.all(): fle.save() # force update of raw_general_contractor + @classmethod + def get_query_owns(cls, user): + return \ + Q(operation_scientist_responsability__collaborators__ishtaruser + =user.ishtaruser) | \ + Q(operation_scientist_responsability__scientist__ishtaruser + =user.ishtaruser) | \ + Q(operation_collaborator__collaborators__ishtaruser + =user.ishtaruser) | \ + Q(operation_collaborator__scientist__ishtaruser + =user.ishtaruser) + class IshtarUser(User): TABLE_COLS = ('username', 'person__name', 'person__surname', |