-
Notifications
You must be signed in to change notification settings - Fork 175
Open
Description
Within FrienshipManager, there are two checks:
django-friendship/friendship/models.py
Lines 290 to 298 in 593d63b
| if FriendshipRequest.objects.filter( | |
| from_user=from_user, to_user=to_user | |
| ).exists(): | |
| raise AlreadyExistsError("You already requested friendship from this user.") | |
| if FriendshipRequest.objects.filter( | |
| from_user=to_user, to_user=from_user | |
| ).exists(): | |
| raise AlreadyExistsError("This user already requested friendship from you.") |
These validate if a request is sent from a from_user or a to_user. These can be converted into a util method to be used from the FrienshipManager rather than copying these two checks outside of the manager if needed.
I have the util method defined like this
def check_if_request_sent(self, from_user, to_user):
if FriendshipRequest.objects.filter(
from_user=from_user, to_user=to_user
).exists():
raise AlreadyExistsError("You already requested friendship from this user.")
if FriendshipRequest.objects.filter(
from_user=to_user, to_user=from_user
).exists():
raise AlreadyExistsError("This user already requested friendship from you.")
Can open a PR, once the idea is approved
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels