From ab66e797fbd122107390cf336277a0e6b51c01f1 Mon Sep 17 00:00:00 2001 From: Hironsan Date: Sun, 28 Feb 2021 11:27:40 +0900 Subject: [PATCH] Add bulk delete for member --- app/api/views/role.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/api/views/role.py b/app/api/views/role.py index 8916c4a6..c835407a 100644 --- a/app/api/views/role.py +++ b/app/api/views/role.py @@ -1,6 +1,7 @@ from django.shortcuts import get_object_or_404 -from rest_framework import generics +from rest_framework import generics, status from rest_framework.permissions import IsAuthenticated +from rest_framework.response import Response from ..models import Project, Role, RoleMapping from ..permissions import IsProjectAdmin @@ -27,6 +28,11 @@ class RoleMappingList(generics.ListCreateAPIView): project = get_object_or_404(Project, pk=self.kwargs['project_id']) serializer.save(project=project) + def delete(self, request, *args, **kwargs): + delete_ids = request.data['ids'] + RoleMapping.objects.filter(pk__in=delete_ids).delete() + return Response(status=status.HTTP_204_NO_CONTENT) + class RoleMappingDetail(generics.RetrieveUpdateDestroyAPIView): queryset = RoleMapping.objects.all()