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


Python ContentApi.archive方法代码示例

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


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

示例1: test_archive

# 需要导入模块: from tracim.lib.content import ContentApi [as 别名]
# 或者: from tracim.lib.content.ContentApi import archive [as 别名]
    def test_archive(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 = uapi.create_user(email='[email protected]',
                                groups=groups, save_now=True)
        workspace = WorkspaceApi(user).create_workspace('test workspace',
                                                        save_now=True)

        api = ContentApi(user)
        item = api.create(ContentType.Folder, workspace, None,
                          'not_archived', True)
        item2 = api.create(ContentType.Folder, workspace, None,
                           'to_archive', True)
        uid = user.user_id
        wid = workspace.workspace_id
        transaction.commit()

        # Refresh instances after commit
        user = uapi.get_one(uid)
        workspace = WorkspaceApi(user).get_one(wid)
        api = ContentApi(user)

        items = api.get_all(None, ContentType.Any, workspace)
        eq_(2, len(items))

        items = api.get_all(None, ContentType.Any, workspace)
        with new_revision(items[0]):
            api.archive(items[0])
        transaction.commit()

        # Refresh instances after commit
        user = uapi.get_one(uid)
        workspace = WorkspaceApi(user).get_one(wid)
        api = ContentApi(user)

        items = api.get_all(None, ContentType.Any, workspace)
        eq_(1, len(items))
        transaction.commit()

        # Refresh instances after commit
        user = uapi.get_one(uid)
        workspace = WorkspaceApi(user).get_one(wid)
        api = ContentApi(user)

        # Test that the item is still available if "show deleted" is activated
        api = ContentApi(None, show_archived=True)
        items = api.get_all(None, ContentType.Any, workspace)
        eq_(2, len(items))
开发者ID:buxx,项目名称:tracim,代码行数:53,代码来源:test_content_api.py

示例2: put_archive

# 需要导入模块: from tracim.lib.content import ContentApi [as 别名]
# 或者: from tracim.lib.content.ContentApi import archive [as 别名]
    def put_archive(self, item_id):
        # TODO - CHECK RIGHTS
        item_id = int(item_id)
        content_api = ContentApi(tmpl_context.current_user)
        item = content_api.get_one(item_id, self._item_type, tmpl_context.workspace)
        try:
            next_url = self._parent_url.format(item.workspace_id, item.parent_id)
            undo_url = self._std_url.format(item.workspace_id, item.parent_id, item.content_id)+'/put_archive_undo'
            msg = _('{} archived. <a class="alert-link" href="{}">Cancel action</a>').format(self._item_type_label, undo_url)

            content_api.archive(item)
            content_api.save(item, ActionDescription.ARCHIVING)

            tg.flash(msg, CST.STATUS_OK, no_escape=True) # TODO allow to come back
            tg.redirect(next_url)
        except ValueError as e:
            next_url = self._std_url.format(item.workspace_id, item.parent_id, item.content_id)
            msg = _('{} not archived: {}').format(self._item_type_label, str(e))
            tg.flash(msg, CST.STATUS_ERROR)
            tg.redirect(next_url)
开发者ID:DarkDare,项目名称:tracim,代码行数:22,代码来源:__init__.py

示例3: test_unit__search_exclude_content_under_deleted_or_archived_parents__ok

# 需要导入模块: from tracim.lib.content import ContentApi [as 别名]
# 或者: from tracim.lib.content.ContentApi import archive [as 别名]
    def test_unit__search_exclude_content_under_deleted_or_archived_parents__ok(self):
        admin = DBSession.query(User).filter(User.email == '[email protected]').one()
        workspace = self._create_workspace_and_test('workspace_1', admin)
        folder_1 = self._create_content_and_test('folder_1', workspace=workspace, type=ContentType.Folder)
        folder_2 = self._create_content_and_test('folder_2', workspace=workspace, type=ContentType.Folder)
        page_1 = self._create_content_and_test('foo', workspace=workspace, type=ContentType.Page, parent=folder_1)
        page_2 = self._create_content_and_test('bar', workspace=workspace, type=ContentType.Page, parent=folder_2)

        api = ContentApi(admin)

        foo_result = api.search(['foo']).all()
        eq_(1, len(foo_result))
        ok_(page_1 in foo_result)

        bar_result = api.search(['bar']).all()
        eq_(1, len(bar_result))
        ok_(page_2 in bar_result)

        with new_revision(folder_1):
            api.delete(folder_1)
        with new_revision(folder_2):
            api.archive(folder_2)

        # Actually ContentApi.search don't filter it
        foo_result = api.search(['foo']).all()
        eq_(1, len(foo_result))
        ok_(page_1 in foo_result)

        bar_result = api.search(['bar']).all()
        eq_(1, len(bar_result))
        ok_(page_2 in bar_result)

        # ContentApi offer exclude_unavailable method to do it
        foo_result = api.search(['foo']).all()
        api.exclude_unavailable(foo_result)
        eq_(0, len(foo_result))

        bar_result = api.search(['bar']).all()
        api.exclude_unavailable(bar_result)
        eq_(0, len(bar_result))
开发者ID:buxx,项目名称:tracim,代码行数:42,代码来源:test_content_api.py

示例4: test_archive_unarchive

# 需要导入模块: from tracim.lib.content import ContentApi [as 别名]
# 或者: from tracim.lib.content.ContentApi import archive [as 别名]
    def test_archive_unarchive(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)]

        user1 = uapi.create_user(email='[email protected]',
                                groups=groups, save_now=True)
        u1id = user1.user_id

        workspace = WorkspaceApi(user1).create_workspace('test workspace',
                                                        save_now=True)
        wid = workspace.workspace_id

        user2 = uapi.create_user()
        user2.email = '[email protected]'
        uapi.save(user2)

        RoleApi(user1).create_one(user2, workspace,
                                  UserRoleInWorkspace.CONTENT_MANAGER,
                                  with_notif=True,
                                  flush=True)

        # show archived is used at the top end of the test
        api = ContentApi(user1, show_archived=True)
        p = api.create(ContentType.File, workspace, None,
                       'this_is_a_page', True)

        u1id = user1.user_id
        u2id = user2.user_id
        pcid = p.content_id
        poid = p.owner_id

        transaction.commit()

        ####

        # refresh after commit
        user1 = UserApi(None).get_one(u1id)
        workspace = WorkspaceApi(user1).get_one(wid)

        content = api.get_one(pcid, ContentType.Any, workspace)
        eq_(u1id, content.owner_id)
        eq_(poid, content.owner_id)

        u2 = UserApi(None).get_one(u2id)
        api2 = ContentApi(u2, show_archived=True)
        content2 = api2.get_one(pcid, ContentType.Any, workspace)
        with new_revision(content2):
            api2.archive(content2)
        api2.save(content2)
        transaction.commit()

        # refresh after commit
        user1 = UserApi(None).get_one(u1id)
        workspace = WorkspaceApi(user1).get_one(wid)
        u2 = UserApi(None).get_one(u2id)
        api = ContentApi(user1, show_archived=True)
        api2 = ContentApi(u2, show_archived=True)

        updated = api2.get_one(pcid, ContentType.Any, workspace)
        eq_(u2id, updated.owner_id,
            'the owner id should be {} (found {})'.format(u2id,
                                                          updated.owner_id))
        eq_(True, updated.is_archived)
        eq_(ActionDescription.ARCHIVING, updated.revision_type)

        ####

        updated2 = api.get_one(pcid, ContentType.Any, workspace)
        with new_revision(updated):
            api.unarchive(updated)
        api.save(updated2)
        eq_(False, updated2.is_archived)
        eq_(ActionDescription.UNARCHIVING, updated2.revision_type)
        eq_(u1id, updated2.owner_id)
开发者ID:buxx,项目名称:tracim,代码行数:78,代码来源:test_content_api.py


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