本文整理汇总了Python中tracim.lib.content.ContentApi.sort_tree_items方法的典型用法代码示例。如果您正苦于以下问题:Python ContentApi.sort_tree_items方法的具体用法?Python ContentApi.sort_tree_items怎么用?Python ContentApi.sort_tree_items使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tracim.lib.content.ContentApi
的用法示例。
在下文中一共展示了ContentApi.sort_tree_items方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _build_sibling_list_of_tree_items
# 需要导入模块: from tracim.lib.content import ContentApi [as 别名]
# 或者: from tracim.lib.content.ContentApi import sort_tree_items [as 别名]
def _build_sibling_list_of_tree_items(self,
workspace: Workspace,
content: Content,
children: [NodeTreeItem],
select_active_node = False,
allowed_content_types: list = [],
ignored_item_ids: list = []) -> (Content, [NodeTreeItem]):
api = ContentApi(tmpl_context.current_user)
tree_items = []
parent = content.parent if content else None
viewable_content_types = self._get_treeviewable_content_types_or_none()
child_contents = api.get_child_folders(parent, workspace, allowed_content_types, ignored_item_ids, viewable_content_types)
for child in child_contents:
children_to_add = children if child==content else []
if child==content and select_active_node:
# The item is the requested node, so we select it
is_selected = True
elif content not in child_contents and select_active_node and child==content:
# The item is not present in the list, so we select its parent node
is_selected = True
else:
is_selected = False
new_item = NodeTreeItem(child, children_to_add, is_selected)
tree_items.append(new_item)
# This allow to show contents and folders group by type
tree_items = ContentApi.sort_tree_items(tree_items)
return parent, tree_items