From 8c128b1062ecf20ce8a830bb0c02e3c22cde2d9d Mon Sep 17 00:00:00 2001 From: sm4640 Date: Wed, 24 Dec 2025 17:45:46 +0900 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Feat:=20[#94]=20=EC=84=9C=EB=B8=8C?= =?UTF-8?q?=EB=8F=84=EB=A9=94=EC=9D=B8=20=EB=8C=80=ED=91=9C=20=ED=8F=AC?= =?UTF-8?q?=ED=8A=B8=ED=8F=B4=EB=A6=AC=EC=98=A4=20id=20=EB=B0=98=ED=99=98?= =?UTF-8?q?=20+=20www=ED=8F=AC=ED=95=A8=20url=20=EA=B8=88=EC=A7=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- users/urls.py | 1 + users/views.py | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/users/urls.py b/users/urls.py index bad61f2..59b7fc2 100644 --- a/users/urls.py +++ b/users/urls.py @@ -23,4 +23,5 @@ urlpatterns = [ path('mypage/works//', MyPageWorkListAPIView.as_view()), path('mypage/my-info/', MyPageMemberInfoAPIView.as_view()), path("github/", include(router.urls)), + path("portfolio/", UserInfoAPIView.as_view()), ] \ No newline at end of file diff --git a/users/views.py b/users/views.py index b3b3684..bacb7ec 100644 --- a/users/views.py +++ b/users/views.py @@ -373,6 +373,12 @@ class SetPortofolioRequiredInfoAPIView(APIView): custom_url = request.GET.get('custom_url', None) if not custom_url: return Response({"message": "no url"}, status=status.HTTP_400_BAD_REQUEST) + + normalized = custom_url.strip().lower() + + if "www" in normalized or "vvvvvv" in normalized: + return Response({"message": "custom_url cannot contain 'www'"}, status=status.HTTP_400_BAD_REQUEST) + if User.objects.filter(custom_url=custom_url).exists(): return Response({"message": "already used url"}, status=status.HTTP_400_BAD_REQUEST) else: @@ -494,3 +500,21 @@ class MyPageMemberInfoAPIView(APIView): return Response(serializer.data, status=status.HTTP_200_OK) return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) +class UserInfoAPIView(APIView): + permission_classes = [AllowAny] + + # 유저 대표 포트폴리오 id 제공 + def get(self, request): + sub_domain = request.query_params.get('sub_domain', '') + + if not sub_domain: + return Response({"message": "no sub domain"}, status=status.HTTP_400_BAD_REQUEST) + + target_user = get_object_or_404(User, custom_url=sub_domain) + represent_portfolio = target_user.owned_portfolios.filter(is_represent=True, is_published=True).first() + + if not represent_portfolio: + return Response({"message": "no represent published portfolio"}, status=status.HTTP_404_NOT_FOUND) + + return Response({"portfolio_id": represent_portfolio.id}, status=status.HTTP_200_OK) +