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


Python ContentApi.set_status方法代码示例

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


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

示例1: put_status

# 需要导入模块: from tracim.lib.content import ContentApi [as 别名]
# 或者: from tracim.lib.content.ContentApi import set_status [as 别名]
 def put_status(self, item_id, status):
     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:
         content_api.set_status(item, status)
         content_api.save(item, ActionDescription.STATUS_UPDATE)
         msg = _('{} status updated').format(self._item_type_label)
         tg.flash(msg, CST.STATUS_OK)
         tg.redirect(self._std_url.format(item.workspace_id, item.parent_id, item.content_id))
     except ValueError as e:
         msg = _('{} status not updated: {}').format(self._item_type_label, str(e))
         tg.flash(msg, CST.STATUS_ERROR)
         tg.redirect(self._err_url.format(item.workspace_id, item.parent_id, item.content_id))
开发者ID:DarkDare,项目名称:tracim,代码行数:16,代码来源:__init__.py

示例2: test_set_status_unknown_status

# 需要导入模块: from tracim.lib.content import ContentApi [as 别名]
# 或者: from tracim.lib.content.ContentApi import set_status [as 别名]
    def test_set_status_unknown_status(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)
        c = api.create(ContentType.Folder, workspace, None, 'parent', True)
        api.set_status(c, 'unknown-status')
开发者ID:DarkDare,项目名称:tracim,代码行数:16,代码来源:test_content_api.py

示例3: test_set_status_ok

# 需要导入模块: from tracim.lib.content import ContentApi [as 别名]
# 或者: from tracim.lib.content.ContentApi import set_status [as 别名]
    def test_set_status_ok(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)
        c = api.create(ContentType.Folder, workspace, None, 'parent', True)
        for new_status in ['open', 'closed-validated', 'closed-unvalidated',
                           'closed-deprecated']:
            api.set_status(c, new_status)
            eq_(new_status, c.status)
            eq_(ActionDescription.STATUS_UPDATE, c.revision_type)
开发者ID:DarkDare,项目名称:tracim,代码行数:20,代码来源:test_content_api.py

示例4: put_status

# 需要导入模块: from tracim.lib.content import ContentApi [as 别名]
# 或者: from tracim.lib.content.ContentApi import set_status [as 别名]
    def put_status(self, item_id, status):
        item_id = int(item_id)
        content_api = ContentApi(tmpl_context.current_user)

        try:
            item = content_api.get_one(item_id, self._item_type,
                                       tmpl_context.workspace)
            with new_revision(item):
                content_api.set_status(item, status)
                content_api.save(item, ActionDescription.STATUS_UPDATE)
            msg = _('{} status updated').format(self._item_type_label)
            tg.flash(msg, CST.STATUS_OK)
            tg.redirect(self._std_url.format(item.workspace_id, item.parent_id, item.content_id))
        except ValueError as e:
            msg = _('{} status not updated: {}').format(self._item_type_label, str(e))
            tg.flash(msg, CST.STATUS_ERROR)
            tg.redirect(self._err_url.format(item.workspace_id, item.parent_id, item.content_id))
        except NoResultFound as e:
            # probably the content is deleted or archived => forbidden to update status
            content_api = ContentApi(
                tmpl_context.current_user,
                show_archived=True,
                show_deleted=True
            )
            item = content_api.get_one(
                item_id,
                self._item_type,
                tmpl_context.workspace
            )

            next_url = self._std_url.format(
                item.workspace_id, item.parent_id, item.content_id
            )
            msg = _('{} status not updated: the operation '
                    'is not allowed on deleted/archived content').format(
                self._item_type_label
            )
            tg.flash(msg, CST.STATUS_ERROR)
            tg.redirect(next_url)
开发者ID:lebouquetin,项目名称:tracim,代码行数:41,代码来源:__init__.py


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