notice but without the t

This commit is contained in:
AdrienLSH
2024-04-25 15:45:32 +02:00
parent dbb8e07d7d
commit 5f58b65a34
29 changed files with 258 additions and 371 deletions

View File

@ -8,7 +8,7 @@ from django.utils.translation import gettext as _
from django.shortcuts import get_object_or_404
from ..models import BlockModel, ProfileModel
from ..serializers.ProfileSerializer import ProfileSerializer
from ..serializers import ProfileSerializer
class GetBlocksView(APIView):

View File

@ -7,7 +7,8 @@ from django.utils.translation import gettext as _
from django.shortcuts import get_object_or_404
from ..models import ProfileModel, FriendRequestModel
from ..serializers.ProfileSerializer import ProfileSerializer
from ..serializers import ProfileSerializer
from notice.consumers import notice_manager
class GetFriendsView(APIView):
@ -41,9 +42,11 @@ class EditFriendView(APIView):
incoming_request = user_profile.get_received_friend_request_from(friend_profile)
if incoming_request:
incoming_request.accept()
return Response(_('Friendship succssfully created.'), status.HTTP_201_CREATED)
notice_manager.notify_new_friend(friend_profile.user, user_profile)
return Response(_('Friendship successfully created.'), status.HTTP_201_CREATED)
FriendRequestModel(author=user_profile, target=friend_profile).save()
notice_manager.notify_friend_request(friend_profile.user, user_profile)
return Response(_('Friend request sent.'), status.HTTP_200_OK)
def delete(self, request, pk=None):
@ -53,13 +56,15 @@ class EditFriendView(APIView):
outgoing_request = user_profile.get_outgoing_friend_request_to(friend_profile)
if outgoing_request:
outgoing_request.delete()
notice_manager.notify_friend_request_canceled(friend_profile.user, user_profile)
return Response(_('Friend request cancelled.'))
if not user_profile.is_friend(friend_profile):
return Response(_('You are not friend with this user.'), status.HTTP_400_BAD_REQUEST)
user_profile.delete_friend(friend_profile)
return Response(_('Friendship succssfully deleted.'), status.HTTP_201_CREATED)
notice_manager.notify_friend_removed(friend_profile.user, user_profile)
return Response(_('Friendship successfully deleted.'), status.HTTP_201_CREATED)
class GetIncomingFriendRequestView(APIView):