本文整理汇总了Python中tracim.lib.content.ContentApi.move_recursively方法的典型用法代码示例。如果您正苦于以下问题:Python ContentApi.move_recursively方法的具体用法?Python ContentApi.move_recursively怎么用?Python ContentApi.move_recursively使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tracim.lib.content.ContentApi
的用法示例。
在下文中一共展示了ContentApi.move_recursively方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: put
# 需要导入模块: from tracim.lib.content import ContentApi [as 别名]
# 或者: from tracim.lib.content.ContentApi import move_recursively [as 别名]
def put(self, item_id, folder_id='0'):
"""
:param item_id:
:param folder_id: id of the folder, in a style like 'workspace_14__content_1586'
:return:
"""
# TODO - SECURE THIS
workspace = tmpl_context.workspace
item_id = int(item_id)
new_workspace, new_parent = convert_id_into_instances(folder_id)
if new_workspace != workspace:
# check that user is at least
# - content manager in current workspace
# - content manager in new workspace
user = tmpl_context.current_user
if user.get_role(workspace) < UserRoleInWorkspace.CONTENT_MANAGER:
tg.flash(_('You are not allowed '
'to move this folder'), CST.STATUS_ERROR)
tg.redirect(self.parent_controller.url(item_id))
if user.get_role(new_workspace) < UserRoleInWorkspace.CONTENT_MANAGER:
tg.flash(_('You are not allowed to move '
'this folder to this workspace'), CST.STATUS_ERROR)
tg.redirect(self.parent_controller.url(item_id))
api = ContentApi(tmpl_context.current_user)
item = api.get_one(item_id, ContentType.Any, workspace)
api.move_recursively(item, new_parent, new_workspace)
next_url = tg.url('/workspaces/{}/folders/{}'.format(
new_workspace.workspace_id, item_id))
if new_parent:
tg.flash(_('Item moved to {} (workspace {})').format(
new_parent.label,
new_workspace.label), CST.STATUS_OK)
else:
tg.flash(_('Item moved to workspace {}').format(
new_workspace.label))
tg.redirect(next_url)
else:
# Default move inside same workspace
api = ContentApi(tmpl_context.current_user)
item = api.get_one(item_id, ContentType.Any, workspace)
api.move(item, new_parent)
next_url = self.parent_controller.url(item_id)
if new_parent:
tg.flash(_('Item moved to {}').format(new_parent.label), CST.STATUS_OK)
else:
tg.flash(_('Item moved to workspace root'))
tg.redirect(next_url)