Skip to content

Commit

Permalink
'FEAT:02-02'
Browse files Browse the repository at this point in the history
  • Loading branch information
jelee2555 committed Aug 29, 2023
1 parent 4b9b64a commit 32ad771
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
Binary file modified accounts/__pycache__/urls.cpython-311.pyc
Binary file not shown.
Binary file modified accounts/__pycache__/views.cpython-311.pyc
Binary file not shown.
3 changes: 2 additions & 1 deletion accounts/urls.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from django.urls import path, include

from accounts.views import SigninAPIView, AuthAPIView, FollowAPIView, UserinfoAPIView
from accounts.views import SigninAPIView, AuthAPIView, FollowAPIView, UserinfoAPIView, UserDetailAPIView

urlpatterns = [
# path('', include('dj_rest_auth.urls')),
Expand All @@ -9,4 +9,5 @@
path('auth/', AuthAPIView.as_view()),
path('follow/', FollowAPIView.as_view()),
path('info/', UserinfoAPIView.as_view()),
path('<int:pk>/', UserDetailAPIView.as_view()),
]
22 changes: 20 additions & 2 deletions accounts/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@ def post(self, request):

class UserinfoAPIView(APIView):
# API 02-01 회원 정보 입력
# BMI 계산 추가
@login_check
def post(self, request):
# User의 userinfo가 존재하는 지 확인
Expand All @@ -187,4 +186,23 @@ def post(self, request):
if serializer.is_valid():
serializer.save()
return Response(serializer.data, status=status.HTTP_200_OK)
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)




class UserDetailAPIView(APIView):
# user_id -> 해당 유저의 상세 정보 조회
def get_object(self, pk):
return get_object_or_404(User, pk=pk)

# API 02-02 회원 정보 조회
def get(self, request, pk):
userinfo = Userinfo.objects.get(user_id=pk)

# 계정 비공개 일 경우
if userinfo.acc_visibility == 0:
return Response({'message': 'This account is Private account'}, status=status.HTTP_400_BAD_REQUEST)

serializer = UserinfoSerializer(userinfo)
return Response(serializer.data, status=status.HTTP_200_OK)

0 comments on commit 32ad771

Please sign in to comment.