Merge pull request #97 from plers-org/sm/#94
✨ Feat: [#94] 서브도메인 대표 포트폴리오 id 반환 + www포함 url 금지
This commit is contained in:
@@ -23,4 +23,5 @@ urlpatterns = [
|
||||
path('mypage/works/<str:nickname>/', MyPageWorkListAPIView.as_view()),
|
||||
path('mypage/my-info/', MyPageMemberInfoAPIView.as_view()),
|
||||
path("github/", include(router.urls)),
|
||||
path("portfolio/", UserInfoAPIView.as_view()),
|
||||
]
|
||||
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user