def get_memberships(self, obj):
"""
Retrieve all nodes where user is a member.
Returns an iterable of objects containing the name and id,
plus a custom field is_recoverable for each workspace.
A workspace is recoverable if it is share among any other user
and its membership status is MemberStatusField.STATUS_MEMBER
:return :dict {'workspace_id': int, 'workspace_name': str,
'is_recoverable': bool}
"""
nodes = Node.objects.all_for_user(obj.created_by)
return imap(
lambda node:
{'workspace_id': node.id, 'workspace_name': node.name,
'is_recoverable': LostKey.objects.is_recoverable(
node.id, obj.created_by)},
nodes)
评论列表
文章目录