From 32ad771542ab99ba5266e96ac887f1e16da19543 Mon Sep 17 00:00:00 2001 From: "jieun4510@sju.ac.kr" Date: Tue, 29 Aug 2023 17:59:28 +0900 Subject: [PATCH] 'FEAT:02-02' --- accounts/__pycache__/urls.cpython-311.pyc | Bin 766 -> 887 bytes accounts/__pycache__/views.cpython-311.pyc | Bin 9575 -> 10834 bytes accounts/urls.py | 3 ++- accounts/views.py | 22 +++++++++++++++++++-- 4 files changed, 22 insertions(+), 3 deletions(-) diff --git a/accounts/__pycache__/urls.cpython-311.pyc b/accounts/__pycache__/urls.cpython-311.pyc index f37187a2c5470c92f9b85a689197ba541e728cb2..ca48bc477ecf71cf5f0dac24378aa9e5a772641e 100644 GIT binary patch delta 264 zcmeyz`khTZ zGAc0pX>v_|&S*VZohgY+0H_vdHAC^P$&;CsltM2s5I~dfGUW+;;AQ7$YTyRJB0ivQ E08R`vIsgCw diff --git a/accounts/__pycache__/views.cpython-311.pyc b/accounts/__pycache__/views.cpython-311.pyc index 0064f72650eb579ed9d7c669565b1ff673188537..06553f989ebdc0e94a121743f4f8c8ef2a999ee1 100644 GIT binary patch delta 1418 zcmZ`(O>7%Q6rS0&ovj^v6E=2=f8wnx#hAvXPJl>|BBcqGMkNVN8%RI|$Gdgb4PG?6 zDJ3!_LOtYwL}3mD2?0IOCTfL4SE;uK__HQ&5> z|2yxEe;eCA6S(I0dlAqlTYoAi4t*Fnh&02`NFB>gcQ!>?3+59>I-ALt2Ym}T%7gVPSs zi_tlJy7Ei(HU~9*6@R^>8IMGn#WcMVmOR~z9j1fwQ@#RY7Z?<2S$-UER<`7E99Nix z!8KS$Kfr49cgNj9<;0Qam^u%uNqCq0D-6uXNJX<)L9?8KFQHjp;Q(C<50~bub)Gd; zGOC(6ZIOmUv6YPDVD1HglgaG{gRP8j;Hz-H-jqQQZk!B(F2xZSY{b{#A7%V80E5}e zvU52#Z$UNZ^!cKiHEM8Q4jpUC5d0o`|@?Dit7p=HbkcGkK@j(HW$tfvW`|z}yAR z(B`#8&3wBtT`L{T$QiL-;8JelH021Bvd+|mC1}1@I;WF9I2tUI%&0NQEYEVVMUzzX zduIMQ05nI6*wW#jrR27h{F<|*WK|llrGYh}F0A<13hysgg@`RgEFn@C{A&w#pr7ZcDn=uGfRf4WSy$+QICaw=QqWTPZ7fjgmGwxP455I$r5T1avt?_cUc z&TGi%u-THgfrZg?@-9JFMu$y8q0HP4K#hzt;+ zGucpDYVvjkQN~r9&noyaDkg(OLBw((E;a!Y4RH8@je$*YvXzoH2S|aYT#@5uc6Cig tHn7W*CtGXCa+Lxl7(qI>ZBEjtWpos0^k@9QfSsI>{t+zm1&2J??*NLnTzvol diff --git a/accounts/urls.py b/accounts/urls.py index 0492553..a34cb24 100644 --- a/accounts/urls.py +++ b/accounts/urls.py @@ -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')), @@ -9,4 +9,5 @@ path('auth/', AuthAPIView.as_view()), path('follow/', FollowAPIView.as_view()), path('info/', UserinfoAPIView.as_view()), + path('/', UserDetailAPIView.as_view()), ] \ No newline at end of file diff --git a/accounts/views.py b/accounts/views.py index 089b07d..a3688a5 100644 --- a/accounts/views.py +++ b/accounts/views.py @@ -166,7 +166,6 @@ def post(self, request): class UserinfoAPIView(APIView): # API 02-01 회원 정보 입력 - # BMI 계산 추가 @login_check def post(self, request): # User의 userinfo가 존재하는 지 확인 @@ -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) \ No newline at end of file + 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) \ No newline at end of file