本文整理汇总了Python中tracim.lib.content.ContentApi.sort_content方法的典型用法代码示例。如果您正苦于以下问题:Python ContentApi.sort_content方法的具体用法?Python ContentApi.sort_content怎么用?Python ContentApi.sort_content使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tracim.lib.content.ContentApi
的用法示例。
在下文中一共展示了ContentApi.sort_content方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_sort_by_content_type
# 需要导入模块: from tracim.lib.content import ContentApi [as 别名]
# 或者: from tracim.lib.content.ContentApi import sort_content [as 别名]
def test_sort_by_content_type(self):
c1 = Content()
c1.label = 'AAAA'
c1.type = 'file'
c2 = Content()
c2.label = 'BBBB'
c2.type = 'folder'
items = [c1, c2]
sorteds = ContentApi.sort_content(items)
eq_(sorteds[0], c2,
'value is {} instead of {}'.format(sorteds[0].content_id,
c2.content_id))
eq_(sorteds[1], c1,
'value is {} instead of {}'.format(sorteds[1].content_id,
c1.content_id))
示例2: test_sort_by_label_or_filename
# 需要导入模块: from tracim.lib.content import ContentApi [as 别名]
# 或者: from tracim.lib.content.ContentApi import sort_content [as 别名]
def test_sort_by_label_or_filename(self):
c1 = Content()
c1.label = 'ABCD'
c1.type = 'file'
c2 = Content()
c2.label = ''
c2.type = 'file'
c2.file_name = 'AABC'
c3 = Content()
c3.label = 'BCDE'
c3.type = 'file'
items = [c1, c2, c3]
sorteds = ContentApi.sort_content(items)
eq_(sorteds[0], c2)
eq_(sorteds[1], c1)
eq_(sorteds[2], c3)
示例3: treeview_children
# 需要导入模块: from tracim.lib.content import ContentApi [as 别名]
# 或者: from tracim.lib.content.ContentApi import sort_content [as 别名]
def treeview_children(self, id='#',
ignore_id=None,
allowed_content_types = None):
"""
id must be "#" or something like "workspace_3__document_8"
"""
if id=='#':
return self.treeview_root()
ignore_item_ids = [int(ignore_id)] if ignore_id else []
workspace, content = convert_id_into_instances(id)
viewable_content_types = []
if allowed_content_types:
viewable_content_types = allowed_content_types.split(',')
else:
viewable_content_types = self._get_treeviewable_content_types_or_none()
contents = ContentApi(tmpl_context.current_user).get_child_folders(content, workspace, [], ignore_item_ids, viewable_content_types)
# This allow to show contents and folders group by type
sorted_contents = ContentApi.sort_content(contents)
dictified_contents = Context(CTX.MENU_API).toDict(sorted_contents, 'd')
return dictified_contents