This commit is contained in:
2024-04-18 20:56:21 +02:00
parent abb7797e48
commit 6b82f00a14
5 changed files with 13 additions and 74 deletions

View File

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