From 95380d049146b2640f5e2ef51a26d64f47910d16 Mon Sep 17 00:00:00 2001 From: fnzksxl Date: Tue, 16 Jul 2024 20:10:27 +0900 Subject: [PATCH] =?UTF-8?q?#63=20Feat:=20Admin=20=EC=84=9C=EB=B9=84?= =?UTF-8?q?=EC=8A=A4=EC=97=90=20=EC=9E=98=EB=AA=BB=EB=90=9C=20=EC=9A=94?= =?UTF-8?q?=EC=B2=AD=EC=97=90=20=EB=8C=80=ED=95=9C=20=EC=BB=A4=EC=8A=A4?= =?UTF-8?q?=ED=85=80=20=EC=97=90=EB=9F=AC=20=EC=BD=94=EB=93=9C=20=EC=9E=91?= =?UTF-8?q?=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- wtnt/admin/team/views.py | 24 +++++++++++++++++++++++- wtnt/admin/user/views.py | 24 +++++++++++++++++++++++- 2 files changed, 46 insertions(+), 2 deletions(-) diff --git a/wtnt/admin/team/views.py b/wtnt/admin/team/views.py index e16b030..774fa1e 100644 --- a/wtnt/admin/team/views.py +++ b/wtnt/admin/team/views.py @@ -1,9 +1,10 @@ from rest_framework import status from rest_framework.response import Response from rest_framework.views import APIView -from core.permissions import IsAdminUser from django.contrib.auth import get_user_model +import core.exception.request as exception +from core.permissions import IsAdminUser from .service import AdminTeamService User = get_user_model() @@ -19,12 +20,26 @@ def get(self, request): return Response(data, status=status.HTTP_200_OK) def patch(self, request, *args, **kwargs): + required_field = ["ids"] + if len(request.data) != len(required_field): + raise exception.InvalidRequestError() + for field in required_field: + if field not in request.data: + raise exception.InvalidRequestError() + admin_service = AdminTeamService(request) data = admin_service.approve_teams() return Response(data, status=status.HTTP_202_ACCEPTED) def delete(self, request, *args, **kwargs): + required_field = ["ids"] + if len(request.data) != len(required_field): + raise exception.InvalidRequestError() + for field in required_field: + if field not in request.data: + raise exception.InvalidRequestError() + admin_service = AdminTeamService(request) data = admin_service.reject_teams(status=False) @@ -39,6 +54,13 @@ def get(self, request): return admin_service.get_approved_teams() def delete(self, request, *args, **kwargs): + required_field = ["ids"] + if len(request.data) != len(required_field): + raise exception.InvalidRequestError() + for field in required_field: + if field not in request.data: + raise exception.InvalidRequestError() + admin_service = AdminTeamService(request) data = admin_service.reject_teams(status=True) diff --git a/wtnt/admin/user/views.py b/wtnt/admin/user/views.py index c2fa31c..506fcc9 100644 --- a/wtnt/admin/user/views.py +++ b/wtnt/admin/user/views.py @@ -1,9 +1,10 @@ from rest_framework import status from rest_framework.response import Response from rest_framework.views import APIView -from core.permissions import IsAdminUser from django.contrib.auth import get_user_model +import core.exception.request as exception +from core.permissions import IsAdminUser from .service import AdminUserService User = get_user_model() @@ -19,12 +20,26 @@ def get(self, request): return Response(data, status=status.HTTP_200_OK) def patch(self, request, *args, **kwargs): + required_field = ["ids"] + if len(request.data) != len(required_field): + raise exception.InvalidRequestError() + for field in required_field: + if field not in request.data: + raise exception.InvalidRequestError() + admin_service = AdminUserService(request) data = admin_service.approve_users() return Response(data, status=status.HTTP_202_ACCEPTED) def delete(self, request, *args, **kwargs): + required_field = ["ids"] + if len(request.data) != len(required_field): + raise exception.InvalidRequestError() + for field in required_field: + if field not in request.data: + raise exception.InvalidRequestError() + admin_service = AdminUserService(request) data = admin_service.reject_users(status=False) @@ -39,6 +54,13 @@ def get(self, request): return admin_service.get_approved_users() def delete(self, request, *args, **kwargs): + required_field = ["ids"] + if len(request.data) != len(required_field): + raise exception.InvalidRequestError() + for field in required_field: + if field not in request.data: + raise exception.InvalidRequestError() + admin_service = AdminUserService(request) data = admin_service.reject_users(status=True)