本文整理汇总了Python中collective.workspace.interfaces.IWorkspace.items方法的典型用法代码示例。如果您正苦于以下问题:Python IWorkspace.items方法的具体用法?Python IWorkspace.items怎么用?Python IWorkspace.items使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类collective.workspace.interfaces.IWorkspace
的用法示例。
在下文中一共展示了IWorkspace.items方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: existing_users
# 需要导入模块: from collective.workspace.interfaces import IWorkspace [as 别名]
# 或者: from collective.workspace.interfaces.IWorkspace import items [as 别名]
def existing_users(context):
"""
Look up the full user details for current workspace members
"""
members = IWorkspace(context).members
info = []
for userid, details in members.items():
user = api.user.get(userid)
if user is None:
continue
user = user.getUser()
title = user.getProperty('fullname') or user.getId() or userid
# XXX tbd, we don't know what a persons description is, yet
description = ''
classes = description and 'has-description' or 'has-no-description'
portal = api.portal.get()
portrait = '%s/@@avatars/%s' % \
(portal.absolute_url(), userid)
info.append(
dict(
id=userid,
title=title,
description=description,
portrait=portrait,
cls=classes,
member=True,
admin='Admins' in details['groups'],
)
)
return info
示例2: existing_users
# 需要导入模块: from collective.workspace.interfaces import IWorkspace [as 别名]
# 或者: from collective.workspace.interfaces.IWorkspace import items [as 别名]
def existing_users(self):
"""
Look up the full user details for current workspace members
"""
members = IWorkspace(self).members
info = []
for userid, details in members.items():
user = api.user.get(userid)
if user is None:
continue
user = user.getUser()
title = user.getProperty('fullname') or user.getId() or userid
# XXX tbd, we don't know what a persons description is, yet
description = MessageFactory(u'Here we could have a nice status of'
u' this person')
classes = description and 'has-description' or 'has-no-description'
portrait = pi_api.userprofile.avatar_url(userid)
info.append(
dict(
id=userid,
title=title,
description=description,
portrait=portrait,
cls=classes,
member=True,
admin='Admins' in details['groups'],
)
)
return info
示例3: existing_users
# 需要导入模块: from collective.workspace.interfaces import IWorkspace [as 别名]
# 或者: from collective.workspace.interfaces.IWorkspace import items [as 别名]
def existing_users(context):
"""
Look up the full user details for current workspace members
"""
members = IWorkspace(context).members
info = []
for userid, details in members.items():
user = api.user.get(userid)
if user is None:
continue
user = user.getUser()
title = user.getProperty("fullname") or user.getId() or userid
# XXX tbd, we don't know what a persons description is, yet
description = _(u"Here we could have a nice status of this person")
classes = description and "has-description" or "has-no-description"
portal = api.portal.get()
portrait = "%s/portal_memberdata/portraits/%s" % (portal.absolute_url(), userid)
info.append(
dict(
id=userid,
title=title,
description=description,
portrait=portrait,
cls=classes,
member=True,
admin="Admins" in details["groups"],
)
)
return info
示例4: existing_users
# 需要导入模块: from collective.workspace.interfaces import IWorkspace [as 别名]
# 或者: from collective.workspace.interfaces.IWorkspace import items [as 别名]
def existing_users(self):
members = IWorkspace(self.context).members
info = []
for userid, details in members.items():
user = api.user.get(userid).getUser()
title = user.getProperty('fullname') or user.getId() or userid
info.append(
dict(
id=userid,
title=title,
member=True,
admin='Admins' in details['groups'],
)
)
return info
示例5: existing_users
# 需要导入模块: from collective.workspace.interfaces import IWorkspace [as 别名]
# 或者: from collective.workspace.interfaces.IWorkspace import items [as 别名]
def existing_users(self):
"""
Look up the full user details for current workspace members
"""
members = IWorkspace(self).members
info = []
for user_or_group_id, details in members.items():
user = api.user.get(user_or_group_id)
if user is not None:
user = user.getUser()
title = (user.getProperty('fullname') or user.getId() or
user_or_group_id)
# XXX tbd, we don't know what a persons description is, yet
description = ''
classes = 'user ' + (description and 'has-description'
or 'has-no-description')
portrait = pi_api.userprofile.avatar_url(user_or_group_id)
else:
group = api.group.get(user_or_group_id)
if group is None:
continue
title = (group.getProperty('title') or group.getId() or
user_or_group_id)
description = _(
u"number_of_members",
default=u'${no_members} Members',
mapping={
u'no_members': len(group.getAllGroupMemberIds())})
classes = 'user-group has-description'
portrait = ''
# User's 'role' is any group they are a member of
# that is not the default participation policy group
# (including Admins group)
role = None
groups = details['groups']
if 'Admins' in groups:
role = 'Admin'
for policy in PARTICIPANT_POLICY:
if policy == self.participant_policy:
continue
if policy.title() in groups:
role = PARTICIPANT_POLICY[policy]['title']
# According to the design there is at most one extra role
# per user, so we go with the first one we find. This may
# not be enforced in the backend though.
break
if role:
classes += ' has-label'
info.append(
dict(
id=user_or_group_id,
title=title,
description=description,
portrait=portrait,
cls=classes,
member=True,
admin='Admins' in details['groups'],
role=role,
)
)
return info