#19 Tests
* refactors sharing user setting by introducing share_with(user) and share_with_list(user_list) for BaseObject for a more self-explanatory sharing
This commit is contained in:
@@ -155,6 +155,29 @@ class BaseObject(BaseResource):
|
||||
else:
|
||||
return User.objects.none()
|
||||
|
||||
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.is_shared_with(user):
|
||||
self.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.users.set(user_list)
|
||||
|
||||
def generate_new_identifier(self) -> str:
|
||||
""" Generates a new identifier for the intervention object
|
||||
|
||||
|
||||
Reference in New Issue
Block a user