当前位置: 首页>>代码示例>>Python>>正文


Python ContentApi.mark_read__workspace方法代码示例

本文整理汇总了Python中tracim.lib.content.ContentApi.mark_read__workspace方法的典型用法代码示例。如果您正苦于以下问题:Python ContentApi.mark_read__workspace方法的具体用法?Python ContentApi.mark_read__workspace怎么用?Python ContentApi.mark_read__workspace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tracim.lib.content.ContentApi的用法示例。


在下文中一共展示了ContentApi.mark_read__workspace方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: mark_read

# 需要导入模块: from tracim.lib.content import ContentApi [as 别名]
# 或者: from tracim.lib.content.ContentApi import mark_read__workspace [as 别名]
    def mark_read(self, workspace_id, **kwargs):

        user = tmpl_context.current_user
        workspace_api = WorkspaceApi(user)
        workspace = workspace_api.get_one(workspace_id)

        content_api = ContentApi(user)
        content_api.mark_read__workspace(workspace)

        tg.redirect('/workspaces/{}'.format(workspace_id))
        return DictLikeClass(fake_api=fake_api)
开发者ID:lebouquetin,项目名称:tracim,代码行数:13,代码来源:workspace.py

示例2: test_mark_read__workspace

# 需要导入模块: from tracim.lib.content import ContentApi [as 别名]
# 或者: from tracim.lib.content.ContentApi import mark_read__workspace [as 别名]
    def test_mark_read__workspace(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)
        workspace1 = wapi.create_workspace(
            'test workspace n°1',
            save_now=True)
        workspace2 = wapi.create_workspace(
            'test workspace n°2',
            save_now=True)

        role_api1 = RoleApi(user_a)
        role_api1.create_one(user_b, workspace1, UserRoleInWorkspace.READER,
                            False)

        role_api2 = RoleApi(user_a)
        role_api2.create_one(user_b, workspace2, UserRoleInWorkspace.READER,
                             False)

        cont_api_a = ContentApi(user_a)
        cont_api_b = ContentApi(user_b)


        # Creates page_1 & page_2 in workspace 1
        #     and page_3 & page_4 in workspace 2
        page_1 = cont_api_a.create(ContentType.Page, workspace1, None,
                                   'this is a page', do_save=True)
        page_2 = cont_api_a.create(ContentType.Page, workspace1, None,
                                   'this is page1', do_save=True)
        page_3 = cont_api_a.create(ContentType.Thread, workspace2, None,
                                   'this is page2', do_save=True)
        page_4 = cont_api_a.create(ContentType.File, workspace2, None,
                                   'this is page3', do_save=True)

        for rev in page_1.revisions:
            eq_(user_b not in rev.read_by.keys(), True)
        for rev in page_2.revisions:
            eq_(user_b not in rev.read_by.keys(), True)
        for rev in page_3.revisions:
            eq_(user_b not in rev.read_by.keys(), True)
        for rev in page_4.revisions:
            eq_(user_b not in rev.read_by.keys(), True)

        # Set as read the workspace n°1
        cont_api_b.mark_read__workspace(workspace=workspace1)

        for rev in page_1.revisions:
            eq_(user_b in rev.read_by.keys(), True)
        for rev in page_2.revisions:
            eq_(user_b in rev.read_by.keys(), True)
        for rev in page_3.revisions:
            eq_(user_b not in rev.read_by.keys(), True)
        for rev in page_4.revisions:
            eq_(user_b not in rev.read_by.keys(), True)

        # Set as read the workspace n°2
        cont_api_b.mark_read__workspace(workspace=workspace2)

        for rev in page_1.revisions:
            eq_(user_b in rev.read_by.keys(), True)
        for rev in page_2.revisions:
            eq_(user_b in rev.read_by.keys(), True)
        for rev in page_3.revisions:
            eq_(user_b in rev.read_by.keys(), True)
        for rev in page_4.revisions:
            eq_(user_b in rev.read_by.keys(), True)
开发者ID:lebouquetin,项目名称:tracim,代码行数:75,代码来源:test_content_api.py


注:本文中的tracim.lib.content.ContentApi.mark_read__workspace方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。