本文整理汇总了Python中tracim_backend.lib.core.content.ContentApi.set_status方法的典型用法代码示例。如果您正苦于以下问题:Python ContentApi.set_status方法的具体用法?Python ContentApi.set_status怎么用?Python ContentApi.set_status使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tracim_backend.lib.core.content.ContentApi
的用法示例。
在下文中一共展示了ContentApi.set_status方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: set_html_document_status
# 需要导入模块: from tracim_backend.lib.core.content import ContentApi [as 别名]
# 或者: from tracim_backend.lib.core.content.ContentApi import set_status [as 别名]
def set_html_document_status(
self,
context,
request: TracimRequest,
hapic_data=None
) -> None:
"""
set html_document status
"""
app_config = request.registry.settings['CFG']
api = ContentApi(
show_archived=True,
show_deleted=True,
current_user=request.current_user,
session=request.dbsession,
config=app_config,
)
content = api.get_one(
hapic_data.path.content_id,
content_type=content_type_list.Any_SLUG
)
with new_revision(
session=request.dbsession,
tm=transaction.manager,
content=content
):
api.set_status(
content,
hapic_data.body.status,
)
api.save(content)
return
示例2: test_api__post_content_comment__err_400__content_not_editable
# 需要导入模块: from tracim_backend.lib.core.content import ContentApi [as 别名]
# 或者: from tracim_backend.lib.core.content.ContentApi import set_status [as 别名]
def test_api__post_content_comment__err_400__content_not_editable(self) -> None:
"""
Get alls comments of a content
"""
dbsession = get_tm_session(self.session_factory, transaction.manager)
admin = dbsession.query(User) \
.filter(User.email == '[email protected]') \
.one() # type: User
workspace_api = WorkspaceApi(
current_user=admin,
session=dbsession,
config=self.app_config
)
business_workspace = workspace_api.get_one(1)
content_api = ContentApi(
current_user=admin,
session=dbsession,
config=self.app_config
)
tool_folder = content_api.get_one(1, content_type=content_type_list.Any_SLUG)
test_thread = content_api.create(
content_type_slug=content_type_list.Thread.slug,
workspace=business_workspace,
parent=tool_folder,
label='Test Thread',
do_save=True,
do_notify=False,
)
with new_revision(
session=dbsession,
tm=transaction.manager,
content=test_thread,
):
content_api.update_content(
test_thread,
new_label='test_thread_updated',
new_content='Just a test'
)
content_api.set_status(test_thread, 'closed-deprecated')
transaction.commit()
self.testapp.authorization = (
'Basic',
(
'[email protected]',
'[email protected]'
)
)
params = {
'raw_content': 'I strongly disagree, Tiramisu win!'
}
res = self.testapp.post_json(
'/api/v2/workspaces/{}/contents/{}/comments'.format(
business_workspace.workspace_id,
test_thread.content_id
),
params=params,
status=400
)
assert res.json_body
assert 'code' in res.json_body
assert res.json_body['code'] == error.CONTENT_IN_NOT_EDITABLE_STATE