diff --git a/awx/api/views.py b/awx/api/views.py index 33cff82049..1d4056587c 100644 --- a/awx/api/views.py +++ b/awx/api/views.py @@ -1868,6 +1868,16 @@ class GroupChildrenList(EnforceParentRelationshipMixin, SubListCreateAttachDetac relationship = 'children' enforce_parent_relationship = 'inventory' + def unattach(self, request, *args, **kwargs): + sub_id = request.data.get('id', None) + if sub_id is not None: + return super(GroupChildrenList, self).unattach(request, *args, **kwargs) + parent = self.get_parent_object() + if not request.user.can_access(self.model, 'delete', parent): + raise PermissionDenied() + parent.delete() + return Response(status=status.HTTP_204_NO_CONTENT) + class GroupPotentialChildrenList(SubListAPIView):