Sous une nuit étoilé, dans la capitale où les habitants font grèves en boucle, un jeune homme du nom d'Adrien, plein d'espoir espérant une douce nuit auprès de sa belle et tendre 'Princesse'. Acheta des capotes premier prix dans la pharmacie non loin de la gare. La suite au prochain commit...

This commit is contained in:
2024-02-01 12:57:32 +01:00
parent 910a8861e5
commit 8c7c5a3637
14 changed files with 67 additions and 40 deletions

View File

@ -10,7 +10,8 @@ urlpatterns = [
path("", viewsets.ProfileViewSet.as_view({'get': 'list'}), name="profiles_list"),
path("block", views.BlocksView.as_view(), name="block_page"),
path("block/<int:pk>", views.BlockView.as_view(), name="block_page"),
path("<str:username>", viewsets.ProfileViewSet.as_view({'get': 'retrieve'}), name="profile_page"),
path("friend", views.FriendsView.as_view(), name="friend_page"),
path("<str:username>", viewsets.ProfileViewSet.as_view({'get': 'retrieve'}), name="profile_page"),
path("id/<int:pk>", viewsets.ProfileViewSet.as_view({'get': 'retrieve_id'}), name="profile_page"),
] + static("/static/avatars/", document_root="./avatars")
] + static("/staqic/avatars/", document_root="./avatars")

View File

@ -70,6 +70,8 @@ class BlocksView(APIView):
return Response("Deleted", status=status.HTTP_200_OK)
class FriendsView(APIView):
permission_classes = (permissions.IsAuthenticated,)
authentication_classes = (SessionAuthentication,)
def get(self, request):
friends = FriendModel().getFriends(request.user.pk)

View File

@ -27,6 +27,15 @@ class ProfileViewSet(viewsets.ModelViewSet):
return Response(self.serializer_class(instance).data,
status=status.HTTP_200_OK)
def retrieve_id(self, request: HttpRequest, pk=None):
user = User.objects.filter(pk=pk)
if (not user):
return Response({"detail": "Profile not found."}, status=status.HTTP_404_NOT_FOUND)
instance = self.queryset().get(pk=user[0].pk)
instance.avatar_url.name = instance.avatar_url.name[instance.avatar_url.name.find("static") - 1:]
return Response(self.serializer_class(instance).data,
status=status.HTTP_200_OK)
def list(self, request: HttpRequest):
serializer = ProfileSerializer(self.queryset(), many=True)
for profile in serializer.data: