Skip to content

Commit

Permalink
access 토큰 없이 특정 리폼러의 data를 가져오는 api 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
kimheonningg committed Jan 4, 2025
1 parent 862974c commit aa2475c
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
2 changes: 2 additions & 0 deletions users/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
ReformerFreelancerView,
)
from users.views.reformer_view.reformer_profile_view import ReformerProfileView
from users.views.reformer_view.reformer_specific_profile_view import ReformerSpecificProfileView
from users.views.token_view.token_view import UserTokenRefreshView, UserTokenVerifyView
from users.views.user_view.user_auth_view import *
from users.views.user_view.user_crud_view import *
Expand All @@ -60,6 +61,7 @@
path("/token/verify", UserTokenVerifyView.as_view(), name="token_verify"),
path("/token/refresh", UserTokenRefreshView.as_view(), name="token_refresh"),
path("/reformer", ReformerProfileView.as_view(), name="reformer"),
path("/reformer/<str:email>", ReformerSpecificProfileView.as_view(), name="specific_reformer"),
path(
"/reformer/education",
ReformerEducationCreateListView.as_view(),
Expand Down
42 changes: 42 additions & 0 deletions users/views/reformer_view/reformer_specific_profile_view.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
from rest_framework import serializers, status
from rest_framework.response import Response
from rest_framework.views import APIView
from rest_framework.permissions import AllowAny

from users.models.user import User
from users.models.reformer import Reformer
from users.serializers.reformer_serializer.reformer_profile_serializer import (
ReformerProfileSerializer,
)
from users.services import UserService

class ReformerSpecificProfileView(APIView):
permission_classes = [AllowAny,]

def get(self, request, email:str) -> Response:
try:
user = User.objects.get(email=email)
reformer_profile = Reformer.objects.get(user=user)
if not reformer_profile:
raise Reformer.DoesNotExist(
"해당 사용자는 리포머 프로필이 등록되어 있지 않습니다."
)
serializer = ReformerProfileSerializer(
instance=reformer_profile, context={"request": request}
)
return Response(serializer.data, status=status.HTTP_200_OK)
except User.DoesNotExist as e:
return Response(
data={"message": str(e)},
status=status.HTTP_404_NOT_FOUND,
)
except Reformer.DoesNotExist as e:
return Response(
data={"message": str(e)},
status=status.HTTP_404_NOT_FOUND,
)
except Exception as e:
return Response(
data={"message": f"{str(e)}"},
status=status.HTTP_500_INTERNAL_SERVER_ERROR,
)

0 comments on commit aa2475c

Please sign in to comment.