本文整理汇总了Python中collective.workspace.interfaces.IWorkspace.membership_factory方法的典型用法代码示例。如果您正苦于以下问题:Python IWorkspace.membership_factory方法的具体用法?Python IWorkspace.membership_factory怎么用?Python IWorkspace.membership_factory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类collective.workspace.interfaces.IWorkspace
的用法示例。
在下文中一共展示了IWorkspace.membership_factory方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: handleApply
# 需要导入模块: from collective.workspace.interfaces import IWorkspace [as 别名]
# 或者: from collective.workspace.interfaces.IWorkspace import membership_factory [as 别名]
def handleApply(self, action):
data = self.extractData()[0]
ws = IWorkspace(self.context)
other_ws_id = data.get("workspace")
other_ws = IWorkspace(api.content.get(UID=other_ws_id))
move = data.get("move", False)
removable = []
for member in ws.members:
user = api.user.get(username=member)
if user is not None:
user_id = user.getId()
other_ws.add_to_team(user=user_id)
removable.append(member)
if move:
func = lambda member: ws.membership_factory(
ws,
{"user": member}).remove_from_team()
map(func, removable)
self.updateWidgets()
self.status = "Members transfered."
示例2: update_users
# 需要导入模块: from collective.workspace.interfaces import IWorkspace [as 别名]
# 或者: from collective.workspace.interfaces.IWorkspace import membership_factory [as 别名]
def update_users(self, entries):
"""Update user properties on the roster """
ws = IWorkspace(self.context)
members = ws.members
# check user permissions against join policy
join_policy = self.context.join_policy
if (join_policy == "admin"
and not checkPermission(
"collective.workspace: Manage roster",
self.context)):
raise Unauthorized("You are not allowed to add users here")
for entry in entries:
id = entry.get('id')
is_member = bool(entry.get('member'))
is_admin = bool(entry.get('admin'))
# Existing members
if id in members:
member = members[id]
if not is_member:
if checkPermission(
"ploneintranet.workspace: Manage workspace",
self.context):
ws.membership_factory(ws, member).remove_from_team()
else:
raise Unauthorized(
"Only team managers can remove members")
elif not is_admin:
ws.membership_factory(ws, member).groups -= {'Admins'}
else:
ws.membership_factory(ws, member).groups |= {'Admins'}
# New members
elif id not in members and (is_member or is_admin):
groups = set()
if is_admin:
groups.add('Admins')
ws.add_to_team(user=id, groups=groups)