# Improve is_shared_with()
* improves central is_shared_with() method of ShareableObjectMixin to run ~30% faster
This commit is contained in:
parent
89c83f8a55
commit
35c7836b5c
@ -501,10 +501,13 @@ class ShareableObjectMixin(models.Model):
|
|||||||
Returns:
|
Returns:
|
||||||
|
|
||||||
"""
|
"""
|
||||||
directly_shared = self.shared_users.filter(id=user.id).exists()
|
obj_shared_teams = self.shared_teams
|
||||||
team_shared = self.shared_teams.filter(
|
obj_shared_users = self.shared_users
|
||||||
users__in=[user]
|
user_shared_teams = user.shared_teams
|
||||||
).exists()
|
|
||||||
|
directly_shared = obj_shared_users.filter(id=user.id).exists()
|
||||||
|
team_shared = (obj_shared_teams & user_shared_teams).exists()
|
||||||
|
|
||||||
is_shared = directly_shared or team_shared
|
is_shared = directly_shared or team_shared
|
||||||
return is_shared
|
return is_shared
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user