本文整理汇总了Python中tracim.lib.workspace.WorkspaceApi.get_one方法的典型用法代码示例。如果您正苦于以下问题:Python WorkspaceApi.get_one方法的具体用法?Python WorkspaceApi.get_one怎么用?Python WorkspaceApi.get_one使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tracim.lib.workspace.WorkspaceApi
的用法示例。
在下文中一共展示了WorkspaceApi.get_one方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_one
# 需要导入模块: from tracim.lib.workspace import WorkspaceApi [as 别名]
# 或者: from tracim.lib.workspace.WorkspaceApi import get_one [as 别名]
def get_one(self, workspace_id):
user = tmpl_context.current_user
current_user_content = Context(CTX.CURRENT_USER).toDict(user)
current_user_content.roles.sort(key=lambda role: role.workspace.name)
workspace_api = WorkspaceApi(user)
workspace = workspace_api.get_one(workspace_id)
dictified_current_user = Context(CTX.CURRENT_USER).toDict(user)
dictified_folders = self.folders.get_all_fake(workspace).result
fake_api = DictLikeClass(
current_user=dictified_current_user,
current_workspace_folders=dictified_folders,
current_user_workspace_role=workspace.get_user_role(user)
)
fake_api.sub_items = Context(CTX.FOLDER_CONTENT_LIST).toDict(
# TODO BS 20161209: Is the correct way to grab folders? No use API?
workspace.get_valid_children(ContentApi.DISPLAYABLE_CONTENTS)
)
dictified_workspace = Context(CTX.WORKSPACE).toDict(workspace, 'workspace')
webdav_url = CFG.get_instance().WSGIDAV_CLIENT_BASE_URL
return DictLikeClass(
result=dictified_workspace,
fake_api=fake_api,
webdav_url=webdav_url,
)
示例2: edit
# 需要导入模块: from tracim.lib.workspace import WorkspaceApi [as 别名]
# 或者: from tracim.lib.workspace.WorkspaceApi import get_one [as 别名]
def edit(self, id):
user = tmpl_context.current_user
workspace_api_controller = WorkspaceApi(user)
workspace = workspace_api_controller.get_one(id)
dictified_workspace = Context(CTX.ADMIN_WORKSPACE).toDict(workspace, 'workspace')
return DictLikeClass(result = dictified_workspace)
示例3: disable_notifications
# 需要导入模块: from tracim.lib.workspace import WorkspaceApi [as 别名]
# 或者: from tracim.lib.workspace.WorkspaceApi import get_one [as 别名]
def disable_notifications(self, workspace_id, next_url=None):
workspace_id = int(workspace_id)
api = WorkspaceApi(tg.tmpl_context.current_user)
workspace = api.get_one(workspace_id)
api.disable_notifications(tg.tmpl_context.current_user, workspace)
tg.flash(_('Notification disabled for workspace {}').format(workspace.label))
if next_url:
tg.redirect(tg.url(next_url))
tg.redirect(self.parent_controller.url(None, 'me'))
示例4: mark_read
# 需要导入模块: from tracim.lib.workspace import WorkspaceApi [as 别名]
# 或者: from tracim.lib.workspace.WorkspaceApi import get_one [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)
示例5: current_workspace
# 需要导入模块: from tracim.lib.workspace import WorkspaceApi [as 别名]
# 或者: from tracim.lib.workspace.WorkspaceApi import get_one [as 别名]
def current_workspace(cls) -> Workspace:
"""
To be used by other conrtollers in order to setup workspace instance in the context
"""
workspace_api = WorkspaceApi(tg.tmpl_context.current_user)
workspace_id = int(tg.request.controller_state.routing_args.get('workspace_id'))
workspace = workspace_api.get_one(workspace_id)
tg.tmpl_context.workspace_id = workspace_id
tg.tmpl_context.workspace = workspace
return workspace
示例6: get_one
# 需要导入模块: from tracim.lib.workspace import WorkspaceApi [as 别名]
# 或者: from tracim.lib.workspace.WorkspaceApi import get_one [as 别名]
def get_one(self, workspace_id, **kwargs):
"""
:param workspace_id: Displayed workspace id
:param kwargs:
* show_deleted: bool: Display deleted contents or hide them if False
* show_archived: bool: Display archived contents or hide them
if False
"""
show_deleted = str_as_bool(kwargs.get('show_deleted', False))
show_archived = str_as_bool(kwargs.get('show_archived', ''))
user = tmpl_context.current_user
workspace_api = WorkspaceApi(user)
workspace = workspace_api.get_one(workspace_id)
unread_contents = ContentApi(user).get_last_unread(None,
ContentType.Any,
workspace=workspace)
current_user_content = Context(CTX.CURRENT_USER).toDict(user)
current_user_content.roles.sort(key=lambda role: role.workspace.name)
dictified_current_user = Context(CTX.CURRENT_USER).toDict(user)
dictified_folders = self.folders.get_all_fake(workspace).result
fake_api = DictLikeClass(
last_unread=Context(CTX.CONTENT_LIST).toDict(unread_contents,
'contents',
'nb'),
current_user=dictified_current_user,
current_workspace_folders=dictified_folders,
current_user_workspace_role=workspace.get_user_role(user)
)
fake_api.sub_items = Context(CTX.FOLDER_CONTENT_LIST).toDict(
# TODO BS 20161209: Is the correct way to grab folders? No use API?
workspace.get_valid_children(
ContentApi.DISPLAYABLE_CONTENTS,
show_deleted=show_deleted,
show_archived=show_archived,
)
)
dictified_workspace = Context(CTX.WORKSPACE).toDict(workspace, 'workspace')
webdav_url = CFG.get_instance().WSGIDAV_CLIENT_BASE_URL
return DictLikeClass(
result=dictified_workspace,
fake_api=fake_api,
webdav_url=webdav_url,
show_deleted=show_deleted,
show_archived=show_archived,
)
示例7: post_delete
# 需要导入模块: from tracim.lib.workspace import WorkspaceApi [as 别名]
# 或者: from tracim.lib.workspace.WorkspaceApi import get_one [as 别名]
def post_delete(self, workspace_id):
workspace_id = int(workspace_id)
api = WorkspaceApi(tg.tmpl_context.current_user)
workspace = api.get_one(workspace_id)
api.delete_one(workspace_id)
workspace_label = workspace.label
undo_url = self.url(workspace_id, self.restore.__name__)
tg.flash(_('{} workspace deleted. In case of error, you can <a class="alert-link" href="{}">restore it</a>.').format(workspace_label, undo_url), CST.STATUS_OK, no_escape=True)
tg.redirect(self.url())
示例8: put
# 需要导入模块: from tracim.lib.workspace import WorkspaceApi [as 别名]
# 或者: from tracim.lib.workspace.WorkspaceApi import get_one [as 别名]
def put(self, id, name, description):
user = tmpl_context.current_user
workspace_api_controller = WorkspaceApi(user)
workspace = workspace_api_controller.get_one(id)
workspace.label = name
workspace.description = description
workspace_api_controller.save(workspace)
tg.flash(_('{} workspace updated.').format(workspace.label), CST.STATUS_OK)
tg.redirect(self.url(workspace.workspace_id))
return
示例9: _before
# 需要导入模块: from tracim.lib.workspace import WorkspaceApi [as 别名]
# 或者: from tracim.lib.workspace.WorkspaceApi import get_one [as 别名]
def _before(self, *args, **kw):
"""
Instantiate the current workspace in tg.tmpl_context
:param args:
:param kw:
:return:
"""
super(self.__class__, self)._before(args, kw)
workspace_api = WorkspaceApi(tg.tmpl_context.current_user)
workspace_id = tg.request.controller_state.routing_args.get('workspace_id')
workspace = workspace_api.get_one(workspace_id)
tg.tmpl_context.workspace_id = workspace_id
tg.tmpl_context.workspace = workspace
示例10: put
# 需要导入模块: from tracim.lib.workspace import WorkspaceApi [as 别名]
# 或者: from tracim.lib.workspace.WorkspaceApi import get_one [as 别名]
def put(self, id, name, description, calendar_enabled: str='off'):
user = tmpl_context.current_user
workspace_api_controller = WorkspaceApi(user)
calendar_enabled = on_off_to_boolean(calendar_enabled)
workspace = workspace_api_controller.get_one(id)
workspace.label = name
workspace.description = description
workspace.calendar_enabled = calendar_enabled
workspace_api_controller.save(workspace)
tg.flash(_('{} workspace updated.').format(workspace.label), CST.STATUS_OK)
tg.redirect(self.url(workspace.workspace_id))
return
示例11: get_one
# 需要导入模块: from tracim.lib.workspace import WorkspaceApi [as 别名]
# 或者: from tracim.lib.workspace.WorkspaceApi import get_one [as 别名]
def get_one(self, workspace_id):
user = tmpl_context.current_user
workspace_api_controller = WorkspaceApi(user)
role_api = RoleApi(tg.tmpl_context.current_user)
user_api = UserApi(tg.tmpl_context.current_user)
workspace = workspace_api_controller.get_one(workspace_id)
role_list = role_api.get_roles_for_select_field()
user_list = user_api.get_all()
current_user_content = Context(CTX.CURRENT_USER).toDict(user)
dictified_workspace = Context(CTX.ADMIN_WORKSPACE).toDict(workspace, 'workspace')
fake_api_content = DictLikeClass(role_types=role_list, users=user_list, current_user=current_user_content)
fake_api = Context(CTX.ADMIN_WORKSPACE).toDict(fake_api_content)
return dict(result = dictified_workspace, fake_api = fake_api)
示例12: get_one
# 需要导入模块: from tracim.lib.workspace import WorkspaceApi [as 别名]
# 或者: from tracim.lib.workspace.WorkspaceApi import get_one [as 别名]
def get_one(self, workspace_id):
user = tmpl_context.current_user
current_user_content = Context(CTX.CURRENT_USER).toDict(user)
current_user_content.roles.sort(key=lambda role: role.workspace.name)
workspace_api = WorkspaceApi(user)
workspace = workspace_api.get_one(workspace_id)
dictified_current_user = Context(CTX.CURRENT_USER).toDict(user)
dictified_folders = self.folders.get_all_fake(workspace).result
fake_api = DictLikeClass(current_user=dictified_current_user,
current_workspace_folders=dictified_folders)\
# ,
# sub_items=Context(CTX.FOLDER_CONTENT_LIST).toDict(dictified_folders))
fake_api.sub_items = Context(CTX.FOLDER_CONTENT_LIST).toDict(workspace.get_valid_children())
dictified_workspace = Context(CTX.WORKSPACE).toDict(workspace, 'workspace')
return DictLikeClass(result = dictified_workspace, fake_api=fake_api)
示例13: put
# 需要导入模块: from tracim.lib.workspace import WorkspaceApi [as 别名]
# 或者: from tracim.lib.workspace.WorkspaceApi import get_one [as 别名]
def put(self, id, name, description, calendar_enabled: str='off'):
user = tmpl_context.current_user
workspace_api_controller = WorkspaceApi(user)
calendar_enabled = on_off_to_boolean(calendar_enabled)
workspace = workspace_api_controller.get_one(id)
# Display error page to user if chosen label is in conflict
if name != workspace.label and \
not self._path_validation.workspace_label_is_free(name):
return render_invalid_integrity_chosen_path(name)
workspace.label = name
workspace.description = description
workspace.calendar_enabled = calendar_enabled
workspace_api_controller.save(workspace)
if calendar_enabled:
workspace_api_controller.ensure_calendar_exist(workspace)
tg.flash(_('{} workspace updated.').format(workspace.label), CST.STATUS_OK)
tg.redirect(self.url(workspace.workspace_id))
return