MCPcopy Index your code
hub / github.com/dataease/SQLBot / ws_change

Function ws_change

backend/apps/system/api/user.py:144–153  ·  view source on GitHub ↗
(session: SessionDep, current_user: CurrentUser, trans:Trans, oid: int = Path(description=f"{PLACEHOLDER_PREFIX}oid"))

Source from the content-addressed store, hash-verified

142 resource_id_expr="editor.id"
143))
144async def ws_change(session: SessionDep, current_user: CurrentUser, trans:Trans, oid: int = Path(description=f"{PLACEHOLDER_PREFIX}oid")):
145 ws_list: list[UserWs] = await user_ws_options(session, current_user.id)
146 if not any(x.id == oid for x in ws_list):
147 db_ws = session.get(WorkspaceModel, oid)
148 if db_ws:
149 raise Exception(trans('i18n_user.ws_miss', ws = db_ws.name))
150 raise Exception(trans('i18n_not_exist', msg = f"{trans('i18n_ws.title')}[{oid}]"))
151 user_model: UserModel = get_db_user(session = session, user_id = current_user.id)
152 user_model.oid = oid
153 session.add(user_model)
154
155@router.get("/{id}", response_model=UserEditor, summary=f"{PLACEHOLDER_PREFIX}user_detail_api", description=f"{PLACEHOLDER_PREFIX}user_detail_api")
156@require_permissions(permission=SqlbotPermission(role=['admin']))

Callers

nothing calls this directly

Calls 4

user_ws_optionsFunction · 0.90
get_db_userFunction · 0.90
getMethod · 0.65
addMethod · 0.65

Tested by

no test coverage detected