From 0d129d14fdfeddda8509c508a95b889134210a2b Mon Sep 17 00:00:00 2001 From: sm4640 Date: Mon, 29 Dec 2025 21:30:50 +0900 Subject: [PATCH] =?UTF-8?q?=E2=9C=8F=EF=B8=8F=20Fix:=20[#99]=20=ED=8F=AC?= =?UTF-8?q?=ED=8F=B4,=20=ED=94=8C=EC=A0=9D=20=EB=8C=80=ED=91=9C/=ED=8D=BC?= =?UTF-8?q?=EB=B8=94=EB=A6=AC=EC=8B=B1=20=EC=88=98=EC=A0=95=20=EB=B0=8F=20?= =?UTF-8?q?=EB=85=B8=EC=BD=94=EB=93=9C=ED=88=B4=20=EC=8A=A4=ED=82=A4?= =?UTF-8?q?=EB=A7=88=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- portfolios/views.py | 18 +++++++++++------- projects/views.py | 18 +++++++++++------- 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/portfolios/views.py b/portfolios/views.py index e715aec..3acaf70 100644 --- a/portfolios/views.py +++ b/portfolios/views.py @@ -54,12 +54,15 @@ class PortfolioSetRepresentAPIView(APIView): portfolio = get_object_or_404(Portfolio, id=pk) if user != portfolio.owner: return Response({"message": "Not owner"}, status=status.HTTP_403_FORBIDDEN) - if before_represent := Portfolio.objects.filter(owner=user, is_represent=True).first(): - before_represent.is_represent = False - before_represent.save() - portfolio.is_represent = True + + is_representing = request.data.get("representing", False) + if is_representing: + if before_represent := Portfolio.objects.filter(owner=user, is_represent=True).first(): + before_represent.is_represent = False + before_represent.save() + portfolio.is_represent = is_representing portfolio.save() - return Response({"message": "change represent success"}, status=status.HTTP_200_OK) + return Response({"is_represented": is_representing}, status=status.HTTP_200_OK) class PortfolioSetPublishAPIView(APIView): @@ -69,9 +72,10 @@ class PortfolioSetPublishAPIView(APIView): portfolio = get_object_or_404(Portfolio, id=pk) if user != portfolio.owner: return Response({"message": "Not owner"}, status=status.HTTP_403_FORBIDDEN) - portfolio.is_published = True + is_publishing = request.data.get("publishing", False) + portfolio.is_published = is_publishing portfolio.save() - return Response({"message": "publish success"}, status=status.HTTP_200_OK) + return Response({"is_published": is_publishing}, status=status.HTTP_200_OK) class PortfolioChangeState(APIView): @transaction.atomic diff --git a/projects/views.py b/projects/views.py index b04368c..44d76f5 100644 --- a/projects/views.py +++ b/projects/views.py @@ -89,12 +89,15 @@ class ProjectSetRepresentAPIView(APIView): project = get_object_or_404(Project, id=pk) if user != project.owner: return Response({"message": "Not owner"}, status=status.HTTP_403_FORBIDDEN) - if before_represent := Project.objects.filter(owner=user, is_represent=True).first(): - before_represent.is_represent = False - before_represent.save() - project.is_represent = True + + is_representing = request.data.get("representing", False) + if is_representing: + if before_represent := Project.objects.filter(owner=user, is_represent=True).first(): + before_represent.is_represent = False + before_represent.save() + project.is_represent = is_representing project.save() - return Response({"message": "change represent success"}, status=status.HTTP_200_OK) + return Response({"is_represented": is_representing}, status=status.HTTP_200_OK) class ProjectSetPublishAPIView(APIView): @@ -104,9 +107,10 @@ class ProjectSetPublishAPIView(APIView): project = get_object_or_404(Project, id=pk) if user != project.owner: return Response({"message": "Not owner"}, status=status.HTTP_403_FORBIDDEN) - project.is_published = True + is_publishing = request.data.get("publishing", False) + project.is_published = is_publishing project.save() - return Response({"message": "publish success"}, status=status.HTTP_200_OK) + return Response({"is_published": is_publishing}, status=status.HTTP_200_OK) class ProjectChangeState(APIView): @transaction.atomic