* adds support for GET and PUT of sharing users for all data types (compensation is shared via intervention)
This commit is contained in:
2022-01-26 09:16:37 +01:00
parent 0b723b1529
commit fc0cd2f086
4 changed files with 157 additions and 2 deletions

View File

@@ -245,6 +245,29 @@ class Compensation(AbstractCompensation, CEFMixin, CoherenceMixin):
# Compensations inherit their shared state from the interventions
return self.intervention.is_shared_with(user)
def share_with(self, user: User):
""" Adds user to list of shared access users
Args:
user (User): The user to be added to the object
Returns:
"""
if not self.intervention.is_shared_with(user):
self.intervention.users.add(user)
def share_with_list(self, user_list: list):
""" Sets the list of shared access users
Args:
user_list (list): The users to be added to the object
Returns:
"""
self.intervention.users.set(user_list)
@property
def shared_users(self) -> QuerySet:
""" Shortcut for fetching the users which have shared access on this object