2023-11-11 18:03:08 -05:00
|
|
|
from django.http import HttpRequest
|
|
|
|
from rest_framework.views import APIView
|
|
|
|
from rest_framework.response import Response
|
|
|
|
from rest_framework import permissions, status
|
2023-10-29 16:09:38 -04:00
|
|
|
|
2023-11-11 18:03:08 -05:00
|
|
|
from .models import ProfileModel
|
2023-10-24 12:28:42 -04:00
|
|
|
|
|
|
|
# Create your views here.
|
2023-11-11 18:03:08 -05:00
|
|
|
class ProfileView(APIView):
|
|
|
|
permission_classes = (permissions.AllowAny,)
|
|
|
|
|
|
|
|
def get(self, request: HttpRequest, pk: int):
|
2023-10-29 16:09:38 -04:00
|
|
|
|
2023-11-11 18:03:08 -05:00
|
|
|
profile: ProfileModel = ProfileModel.objects.get(pk=pk)
|
|
|
|
if (profile is None):
|
|
|
|
return Response(status=status.HTTP_404_NOT_FOUND)
|
2023-10-29 16:09:38 -04:00
|
|
|
|
2023-11-11 18:03:08 -05:00
|
|
|
return Response(status=status.HTTP_200_OK, data={'name': profile.user.username,
|
2023-10-29 16:09:38 -04:00
|
|
|
'title': profile.title})
|