# 308 To share info message

* adds needs-to-be-shared info message on entries which are only shared with the current user
This commit is contained in:
2023-03-07 07:17:08 +01:00
parent 4d3831f30b
commit f22b45b82b
9 changed files with 212 additions and 119 deletions

View File

@@ -516,6 +516,24 @@ class ShareableObjectMixin(models.Model):
is_shared = directly_shared or team_shared
return is_shared
def is_only_shared_with(self, user):
""" Sharing check
Checks whether a given user is the only shared user for this object.
There should be no shared teams as well.
Args:
user ():
Returns:
"""
has_shared_teams = self.shared_teams.exists()
shared_users = self.shared_users
is_only_shared_user = user in shared_users and shared_users.count() == 1
return not has_shared_teams and is_only_shared_user
def share_with_team(self, team):
""" Adds team to list of shared access teans