本文整理汇总了Python中tracim.lib.content.ContentApi.mark_read方法的典型用法代码示例。如果您正苦于以下问题:Python ContentApi.mark_read方法的具体用法?Python ContentApi.mark_read怎么用?Python ContentApi.mark_read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tracim.lib.content.ContentApi
的用法示例。
在下文中一共展示了ContentApi.mark_read方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_mark_read
# 需要导入模块: from tracim.lib.content import ContentApi [as 别名]
# 或者: from tracim.lib.content.ContentApi import mark_read [as 别名]
def test_mark_read(self):
uapi = UserApi(None)
groups = [GroupApi(None).get_one(Group.TIM_USER),
GroupApi(None).get_one(Group.TIM_MANAGER),
GroupApi(None).get_one(Group.TIM_ADMIN)]
user_a = uapi.create_user(email='[email protected]',
groups=groups, save_now=True)
user_b = uapi.create_user(email='[email protected]',
groups=groups, save_now=True)
wapi = WorkspaceApi(user_a)
workspace = wapi.create_workspace(
'test workspace',
save_now=True)
role_api = RoleApi(user_a)
role_api.create_one(user_b, workspace, UserRoleInWorkspace.READER, False)
cont_api_a = ContentApi(user_a)
cont_api_b = ContentApi(user_b)
page_1 = cont_api_a.create(ContentType.Page, workspace, None,
'this is a page', do_save=True)
for rev in page_1.revisions:
eq_(user_b not in rev.read_by.keys(), True)
cont_api_b.mark_read(page_1)
for rev in page_1.revisions:
eq_(user_b in rev.read_by.keys(), True)
示例2: put_read
# 需要导入模块: from tracim.lib.content import ContentApi [as 别名]
# 或者: from tracim.lib.content.ContentApi import mark_read [as 别名]
def put_read(self, item_id):
item_id = int(item_id)
content_api = ContentApi(tmpl_context.current_user, True, True) # Here we do not filter deleted items
item = content_api.get_one(item_id, self._item_type, tmpl_context.workspace)
item_url = self._std_url.format(item.workspace_id, item.parent_id, item.content_id)
try:
msg = _('{} marked as read.').format(self._item_type_label)
content_api.mark_read(item)
tg.flash(msg, CST.STATUS_OK)
tg.redirect(item_url)
except ValueError as e:
logger.debug(self, 'Exception: {}'.format(e.__str__))
msg = _('{} not marked as read: {}').format(self._item_type_label, str(e))
tg.flash(msg, CST.STATUS_ERROR)
tg.redirect(item_url)