def post(self, request, team_name, *args, **kwargs): """ 修改团队名 --- parameters: - name: team_name description: 旧团队名 required: true type: string paramType: path - name: new_team_alias description: 新团队名 required: true type: string paramType: body """ new_team_alias = request.data.get("new_team_alias", "") if new_team_alias: try: code = 200 team = team_services.update_tenant_alias( tenant_name=team_name, new_team_alias=new_team_alias) result = general_message(code, "update success", "团队名修改成功", bean=team.to_dict()) except Exception as e: code = 500 result = general_message(code, "update failed", "团队名修改失败") logger.exception(e) else: result = general_message(400, "failed", "修改的团队名不能为空") code = 400 return Response(result, status=code)
def post(self, request, team_name, *args, **kwargs): """ 修改团队名 --- parameters: - name: team_name description: 旧团队名 required: true type: string paramType: path - name: new_team_alias description: 新团队名 required: true type: string paramType: body """ try: perms = team_services.get_user_perm_identitys_in_permtenant( user_id=request.user.user_id, tenant_name=team_name) perm_tuple = team_services.get_user_perm_in_tenant( user_id=request.user.user_id, tenant_name=team_name) no_auth = True if "owner" in perms or "modify_team_name" in perm_tuple: no_auth = False if no_auth: code = 400 result = general_message(code, "no identity", "权限不足不能修改团队名") else: new_team_alias = request.data.get("new_team_alias", "") if new_team_alias: try: code = 200 team = team_services.update_tenant_alias( tenant_name=team_name, new_team_alias=new_team_alias) result = general_message(code, "update success", "团队名修改成功", bean=team.to_dict()) except Exception as e: code = 500 result = general_message(code, "update failed", "团队名修改失败") logger.exception(e) else: result = general_message(400, "failed", "修改的团队名不能为空") code = 400 except Exception as e: code = 500 result = general_message(code, "update failed", "团队名修改失败") logger.exception(e) return Response(result, status=code)