You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
raiseAlreadyExistsError("You already requested friendship from this user.")
ifFriendshipRequest.objects.filter(
from_user=to_user, to_user=from_user
).exists():
raiseAlreadyExistsError("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
The text was updated successfully, but these errors were encountered:
Within
FrienshipManager
, there are two checks:django-friendship/friendship/models.py
Lines 290 to 298 in 593d63b
These validate if a request is sent from a
from_user
or ato_user
. These can be converted into autil
method to be used from theFrienshipManager
rather than copying these two checks outside of the manager if needed.I have the util method defined like this
Can open a PR, once the idea is approved
The text was updated successfully, but these errors were encountered: