本文整理汇总了Python中tracim.model.data.Content.created_as_delta方法的典型用法代码示例。如果您正苦于以下问题:Python Content.created_as_delta方法的具体用法?Python Content.created_as_delta怎么用?Python Content.created_as_delta使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tracim.model.data.Content
的用法示例。
在下文中一共展示了Content.created_as_delta方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: serialize_node_for_thread
# 需要导入模块: from tracim.model.data import Content [as 别名]
# 或者: from tracim.model.data.Content import created_as_delta [as 别名]
def serialize_node_for_thread(item: Content, context: Context):
if item.type in (ContentType.Thread, ContentType.Task, ContentType.Ticket):
return DictLikeClass(
content = item.description,
created = item.created,
updated = item.last_revision.updated,
revision_nb = len(item.revisions),
icon = ContentType.get_icon(item.type),
id = item.content_id,
label = item.label,
links=[],
owner = context.toDict(item.owner),
last_modification_author=context.toDict(item.last_revision.owner),
parent = context.toDict(item.parent),
selected_revision = 'latest',
status = context.toDict(item.get_status()),
type = item.type,
workspace = context.toDict(item.workspace),
comments = reversed(context.toDict(item.get_comments())),
is_new=item.has_new_information_for(context.get_user()),
history = Context(CTX.CONTENT_HISTORY).toDict(item.get_history()),
is_editable=item.is_editable,
is_deleted=item.is_deleted,
is_archived=item.is_archived,
urls = context.toDict({
'mark_read': context.url(Content.format_path('/workspaces/{wid}/folders/{fid}/{ctype}s/{cid}/put_read', item)),
'mark_unread': context.url(Content.format_path('/workspaces/{wid}/folders/{fid}/{ctype}s/{cid}/put_unread', item))
}),
)
if item.type == ContentType.Comment:
return DictLikeClass(
is_new=item.has_new_information_for(context.get_user()),
content = item.description,
created = item.created,
created_as_delta = item.created_as_delta(),
icon = ContentType.get_icon(item.type),
id = item.content_id,
label = item.label,
owner = context.toDict(item.owner),
# REMOVE parent = context.toDict(item.parent),
type = item.type,
urls = context.toDict({
'delete': context.url('/workspaces/{wid}/folders/{fid}/{ctype}/{cid}/comments/{commentid}/put_delete'.format(wid = item.workspace_id, fid=item.parent.parent_id, ctype=item.parent.type+'s', cid=item.parent.content_id, commentid=item.content_id))
})
)
if item.type==ContentType.Folder:
return Context(CTX.DEFAULT).toDict(item)