コード例 #1
0
 def delete(self, req, user_id, *args, **kwargs):
     if str(req.user.user_id) == user_id:
         raise serializers.ValidationError({"msg": "不能删除自己"}, status.HTTP_400_BAD_REQUEST)
     try:
         user_services.delete_admin_user(user_id)
         return Response(None, status.HTTP_200_OK)
     except ErrAdminUserDoesNotExist as e:
         raise exceptions.NotFound(detail="用户'{}'不是企业管理员".format(user_id))
     except ErrCannotDelLastAdminUser as e:
         raise serializers.ValidationError({"msg": e.message}, status.HTTP_400_BAD_REQUEST)
コード例 #2
0
 def delete(self, request, enterprise_id, user_id, *args, **kwargs):
     if str(request.user.user_id) == user_id:
         result = general_message(400, "fail", "不可删除自己")
         return Response(result, 400)
     try:
         user_services.delete_admin_user(user_id)
         result = general_message(200, "success", None)
         return Response(result, 200)
     except ErrAdminUserDoesNotExist as e:
         logger.debug(e)
         result = general_message(400, "用户'{}'不是企业管理员".format(user_id), None)
         return Response(result, 400)
     except ErrCannotDelLastAdminUser as e:
         logger.debug(e)
         result = general_message(400, "fail", None)
         return Response(result, 400)