profiles: friend requests

This commit is contained in:
AdrienLSH
2024-04-18 11:40:42 +02:00
parent 5a2da91d6e
commit 9f61cda73f
4 changed files with 73 additions and 8 deletions

View File

@ -44,7 +44,7 @@ class ProfileModel(Model):
).delete()
def is_friend_requested_by(self, profile):
return self.get_received_friend_request_from(profile) is None
return FriendRequestModel.objects.filter(author=profile, target=self).exists()
def get_received_friend_request_from(self, profile):
return FriendRequestModel.objects.filter(author=profile, target=self).first()
@ -52,10 +52,13 @@ class ProfileModel(Model):
def is_friend_requesting(self, profile):
return FriendRequestModel.objects.filter(author=self, target=profile).exists()
def get_sent_friend_requests(self) -> list[ProfileModel]:
def get_outgoing_friend_request_to(self, profile):
return FriendRequestModel.objects.filter(author=self, target=profile).first()
def get_outgoing_friend_requests(self) -> list[ProfileModel]:
return FriendRequestModel.objects.filter(author=self)
def get_received_friend_requests(self) -> list[ProfileModel]:
def get_incoming_friend_requests(self) -> list[ProfileModel]:
return FriendRequestModel.objects.filter(target=self)