本文整理汇总了Python中tracim.lib.workspace.WorkspaceApi类的典型用法代码示例。如果您正苦于以下问题:Python WorkspaceApi类的具体用法?Python WorkspaceApi怎么用?Python WorkspaceApi使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了WorkspaceApi类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: _build_sibling_list_of_workspaces
def _build_sibling_list_of_workspaces(self, workspace: Workspace, child_contents: [NodeTreeItem], select_active_workspace = False, all_workspaces = True) -> [NodeTreeItem]:
root_items = []
api = WorkspaceApi(tmpl_context.current_user)
workspaces = api.get_all_for_user(tmpl_context.current_user)
if not all_workspaces:
# Show only current workspace - this is used for "move item" screen
# which must not allow to move from a workspace to another
item = NodeTreeItem(workspace, child_contents)
item.is_selected = select_active_workspace
root_items.append(item)
else:
for workspace_cursor in workspaces:
item = None
if workspace_cursor==workspace:
item = NodeTreeItem(workspace_cursor, child_contents)
else:
item = NodeTreeItem(workspace_cursor, [])
item.is_selected = select_active_workspace and workspace_cursor==workspace
root_items.append(item)
return root_items
开发者ID:lebouquetin,项目名称:tracim,代码行数:25,代码来源:workspace.py
示例2: test_mark_read
def test_mark_read(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)
workspace = wapi.create_workspace(
'test workspace',
save_now=True)
role_api = RoleApi(user_a)
role_api.create_one(user_b, workspace, UserRoleInWorkspace.READER, False)
cont_api_a = ContentApi(user_a)
cont_api_b = ContentApi(user_b)
page_1 = cont_api_a.create(ContentType.Page, workspace, None,
'this is a page', do_save=True)
for rev in page_1.revisions:
eq_(user_b not in rev.read_by.keys(), True)
cont_api_b.mark_read(page_1)
for rev in page_1.revisions:
eq_(user_b in rev.read_by.keys(), True)
开发者ID:lebouquetin,项目名称:tracim,代码行数:30,代码来源:test_content_api.py
示例3: test_func__rights_read_workspace_calendar__fail__as_unauthorized
def test_func__rights_read_workspace_calendar__fail__as_unauthorized(self):
lawrence = DBSession.query(User).filter(
User.email == '[email protected]'
).one()
workspace = WorkspaceApi(lawrence).create_workspace(
'workspace_1',
save_now=False
)
workspace.calendar_enabled = True
DBSession.flush()
workspace_calendar_url = CalendarManager.get_workspace_calendar_url(
workspace.workspace_id
)
transaction.commit()
radicale_base_url = CalendarManager.get_base_url()
client = caldav.DAVClient(
radicale_base_url,
username='[email protected]',
password='foobarbaz'
)
caldav.Calendar(
parent=client,
client=client,
url=workspace_calendar_url
).events()
开发者ID:lebouquetin,项目名称:tracim,代码行数:28,代码来源:test_calendar.py
示例4: get_one
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,
)
开发者ID:buxx,项目名称:tracim,代码行数:30,代码来源:workspace.py
示例5: edit
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)
开发者ID:Nonolost,项目名称:tracim,代码行数:8,代码来源:workspace.py
示例6: get_workspace_readable_calendars_for_user
def get_workspace_readable_calendars_for_user(cls, user: User)\
-> ['Workspace']:
workspaces = []
workspace_api = WorkspaceApi(user)
for workspace in workspace_api.get_all():
if workspace.calendar_enabled:
workspaces.append(workspace)
return workspaces
开发者ID:buxx,项目名称:tracim,代码行数:10,代码来源:calendar.py
示例7: post
def post(self, name, description):
# FIXME - Check user profile
user = tmpl_context.current_user
workspace_api_controller = WorkspaceApi(user)
workspace = workspace_api_controller.create_workspace(name, description)
tg.flash(_('{} workspace created.').format(workspace.label), CST.STATUS_OK)
tg.redirect(self.url())
return
开发者ID:DarkDare,项目名称:tracim,代码行数:10,代码来源:workspace.py
示例8: index
def index(self):
# NOTE BS 20161025: I can't use tmpl_context.current_user,
# I d'ont know why
workspace_api = WorkspaceApi(tmpl_context.identity.get('user'))
workspaces = workspace_api.get_all()
serialized_workspaces = Context(CTX.API_WORKSPACE).toDict(workspaces)
return {
'value_list': serialized_workspaces
}
开发者ID:buxx,项目名称:tracim,代码行数:10,代码来源:api.py
示例9: treeview_root
def treeview_root(self, id='#',
current_id=None,
all_workspaces=True,
folder_allowed_content_types='',
ignore_id=None,
ignore_workspace_id=None):
all_workspaces = bool(int(all_workspaces))
# ignore_workspace_id is a string like 3,12,78,15
ignored_ids = [int(id) for id in ignore_workspace_id.split(',')] if ignore_workspace_id else None
if not current_id:
# Default case is to return list of workspaces
api = WorkspaceApi(tmpl_context.current_user)
workspaces = api.get_all_for_user(tmpl_context.current_user,
ignored_ids)
dictified_workspaces = Context(CTX.MENU_API).toDict(workspaces, 'd')
return dictified_workspaces
allowed_content_types = ContentType.allowed_types_from_str(folder_allowed_content_types)
ignored_item_ids = [int(ignore_id)] if ignore_id else []
# Now complex case: we must return a structured tree
# including the selected node, all parents (and their siblings)
workspace, content = convert_id_into_instances(current_id)
# The following step allow to select the parent folder when content itself is not visible in the treeview
if content and content.type!=ContentType.Folder and CFG.CST.TREEVIEW_ALL!=CFG.get_instance().WEBSITE_TREEVIEW_CONTENT:
content = content.parent if content.parent else None
# This is the init of the recursive-like build of the tree
content_parent = content
tree_items = []
# The first step allow to load child of selected item
# (for example, when you select a folder in the windows explorer,
# then the selected folder is expanded by default)
content_api = ContentApi(tmpl_context.current_user)
child_folders = content_api.get_child_folders(content_parent, workspace, allowed_content_types, ignored_item_ids)
if len(child_folders)>0:
first_child = child_folders[0]
content_parent, tree_items = self._build_sibling_list_of_tree_items(workspace, first_child, tree_items, False, allowed_content_types, ignored_item_ids)
content_parent, tree_items = self._build_sibling_list_of_tree_items(workspace, content_parent, tree_items, True, allowed_content_types, ignored_item_ids)
while content_parent:
# Do the same for the parent level
content_parent, tree_items = self._build_sibling_list_of_tree_items(workspace, content_parent, tree_items)
# Now, we have a tree_items list that is the root folders list,
# so we now have to put it as a child of a list of workspaces
should_select_workspace = not content
full_tree = self._build_sibling_list_of_workspaces(workspace, tree_items, should_select_workspace, all_workspaces)
return Context(CTX.MENU_API_BUILD_FROM_TREE_ITEM).toDict(full_tree, 'd')
开发者ID:lebouquetin,项目名称:tracim,代码行数:55,代码来源:workspace.py
示例10: disable_notifications
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'))
开发者ID:DarkDare,项目名称:tracim,代码行数:11,代码来源:user.py
示例11: get_workspace_readable_calendars_urls_for_user
def get_workspace_readable_calendars_urls_for_user(cls, user: User)\
-> [str]:
calendar_urls = []
workspace_api = WorkspaceApi(user)
for workspace in workspace_api.get_all_for_user(user):
if workspace.calendar_enabled:
calendar_urls.append(cls.get_workspace_calendar_url(
workspace_id=workspace.workspace_id,
))
return calendar_urls
开发者ID:Nonolost,项目名称:tracim,代码行数:11,代码来源:calendar.py
示例12: restore
def restore(self, workspace_id):
workspace_id = int(workspace_id)
api = WorkspaceApi(tg.tmpl_context.current_user)
workspace = api.restore_one(workspace_id, True)
workspace_label = workspace.label
undo_url = self.url(workspace_id, 'delete')
tg.flash(_('{} workspace restored.').format(workspace_label), CST.STATUS_OK)
tg.redirect(self.url())
开发者ID:Nonolost,项目名称:tracim,代码行数:11,代码来源:workspace.py
示例13: mark_read
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,代码行数:11,代码来源:workspace.py
示例14: post_delete
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())
开发者ID:Nonolost,项目名称:tracim,代码行数:12,代码来源:workspace.py
示例15: put
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
开发者ID:DarkDare,项目名称:tracim,代码行数:12,代码来源:workspace.py
示例16: get_all
def get_all(self, *args, **kw):
user = tmpl_context.current_user
workspace_api_controller = WorkspaceApi(user)
workspaces = workspace_api_controller.get_all()
current_user_content = Context(CTX.CURRENT_USER).toDict(user)
fake_api = Context(CTX.ADMIN_WORKSPACE).toDict({'current_user': current_user_content})
dictified_workspaces = Context(CTX.ADMIN_WORKSPACES).toDict(workspaces, 'workspaces', 'workspace_nb')
return DictLikeClass(result = dictified_workspaces, fake_api=fake_api)
开发者ID:Nonolost,项目名称:tracim,代码行数:12,代码来源:workspace.py
示例17: current_workspace
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
开发者ID:buxx,项目名称:tracim,代码行数:12,代码来源:__init__.py
示例18: get_one
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,
)
开发者ID:lebouquetin,项目名称:tracim,代码行数:53,代码来源:workspace.py
示例19: post
def post(self, name, description, calendar_enabled: str='off'):
# FIXME - Check user profile
user = tmpl_context.current_user
workspace_api_controller = WorkspaceApi(user)
calendar_enabled = on_off_to_boolean(calendar_enabled)
workspace = workspace_api_controller.create_workspace(name, description)
workspace.calendar_enabled = calendar_enabled
DBSession.flush()
tg.flash(_('{} workspace created.').format(workspace.label), CST.STATUS_OK)
tg.redirect(self.url())
return
开发者ID:Nonolost,项目名称:tracim,代码行数:13,代码来源:workspace.py
示例20: test_get_notifiable_roles
def test_get_notifiable_roles(self):
admin = DBSession.query(User) \
.filter(User.email == '[email protected]').one()
wapi = WorkspaceApi(admin)
w = wapi.create_workspace(label='workspace w', save_now=True)
uapi = UserApi(admin)
u = uapi.create_user(email='[email protected]', save_now=True)
eq_([], wapi.get_notifiable_roles(workspace=w))
rapi = RoleApi(u)
r = rapi.create_one(u, w, UserRoleInWorkspace.READER, with_notif=True)
eq_([r, ], wapi.get_notifiable_roles(workspace=w))
u.is_active = False
eq_([], wapi.get_notifiable_roles(workspace=w))
开发者ID:lebouquetin,项目名称:tracim,代码行数:13,代码来源:test_workspace.py
注:本文中的tracim.lib.workspace.WorkspaceApi类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论