Beispiel #1
0
 def get(self, request, team_name, *args, **kwargs):
     """
     退出当前团队
     ---
     parameters:
         - name: team_name
           description: 当前所在的团队
           required: true
           type: string
           paramType: path
     """
     if "owner" in team_services.get_user_perm_identitys_in_permtenant(
             user_id=request.user.user_id, tenant_name=team_name):
         result = general_message(409, "not allow exit.",
                                  "您是当前团队最高管理员,不能退出此团队")
     else:
         try:
             code, msg_show = team_services.exit_current_team(
                 team_name=team_name, user_id=request.user.user_id)
             if code == 200:
                 result = general_message(code=code,
                                          msg="success",
                                          msg_show=msg_show)
             else:
                 result = general_message(code=code,
                                          msg="failed",
                                          msg_show=msg_show)
         except Exception as e:
             logger.exception(e)
             result = error_message(e.message)
     return Response(result, status=result["code"])
Beispiel #2
0
 def get(self, request, team_name, *args, **kwargs):
     """
     退出当前团队
     ---
     parameters:
         - name: team_name
           description: 当前所在的团队
           required: true
           type: string
           paramType: path
     """
     if self.is_team_owner:
         return Response(general_message(409, "not allow exit.",
                                         "您是当前团队创建者,不能退出此团队"),
                         status=409)
     code, msg_show = team_services.exit_current_team(
         team_name=team_name, user_id=request.user.user_id)
     if code == 200:
         result = general_message(code=code,
                                  msg="success",
                                  msg_show=msg_show)
     else:
         result = general_message(code=code,
                                  msg="failed",
                                  msg_show=msg_show)
     return Response(result, status=result.get("code", 200))
Beispiel #3
0
    def get(self, request, team_name, *args, **kwargs):
        """
        退出当前团队
        ---
        parameters:
            - name: team_name
              description: 当前所在的团队
              required: true
              type: string
              paramType: path
        """

        identity_list = team_services.get_user_perm_identitys_in_permtenant(
            user_id=request.user.user_id, tenant_name=team_name)

        role_name_list = team_services.get_user_perm_role_in_permtenant(
            user_id=request.user.user_id, tenant_name=team_name)

        if "owner" in identity_list:
            result = general_message(409, "not allow exit.",
                                     "您是当前团队创建者,不能退出此团队")
            return Response(result, status=409)
        if "admin" in identity_list:
            result = general_message(409, "not allow exit.",
                                     "您是当前团队管理员,不能退出此团队")
            return Response(result, status=409)

        if "owner" in role_name_list:
            result = general_message(409, "not allow exit.",
                                     "您是当前团队创建者,不能退出此团队")
            return Response(result, status=409)
        if "admin" in role_name_list:
            result = general_message(409, "not allow exit.",
                                     "您是当前团队管理员,不能退出此团队")
            return Response(result, status=409)

        try:
            if request.user.nick_name == "rainbond-demo" and team_name == "a5qw69mz":
                return Response(general_message(403, "permission denied!",
                                                "您无法退出此团队"),
                                status=403)

            code, msg_show = team_services.exit_current_team(
                team_name=team_name, user_id=request.user.user_id)
            if code == 200:
                result = general_message(code=code,
                                         msg="success",
                                         msg_show=msg_show)
            else:
                result = general_message(code=code,
                                         msg="failed",
                                         msg_show=msg_show)
        except Exception as e:
            logger.exception(e)
            result = error_message(e.message)
        return Response(result, status=result["code"])