Exemple #1
0
    def get_principal_roles(self, principal):
        ''' Get the description for this principalid
        '''
        adapter = IWorkspace(self.context)
        if hasattr(principal, 'getGroupId'):
            groups = adapter.get(principal.getGroupId()).groups
        else:
            groups = adapter.get(principal.getId()).groups

        if 'Admins' in groups:
            return ['Admin']

        # The policies are ordered from the less permissive to the most
        # permissive. We reverse them
        for policy in reversed(PARTICIPANT_POLICY):
            # BBB: code copied from the workspacefolder existing_users function
            # at 58c758d20a820dcb9f691168a9215bfc9741b00e
            # not really clear to me why we are skipping the current policy
            if policy != self.context.participant_policy:
                if policy.title() in groups:
                    # 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.
                    return [PARTICIPANT_POLICY[policy]['title']]

        if groups == {'Guests'}:
            return ['Guest']
        return []
Exemple #2
0
 def guest_ids(self):
     ''' Get the valid member ids through IWorkspace
     '''
     adapter = IWorkspace(self.context)
     return [
         principalid for principalid in self.member_ids
         if adapter.get(principalid).groups == {'Guests'}
     ]
def participation_policy_changed(ob, event):
    """ Move all the existing users to a new group """
    workspace = IWorkspace(ob)
    old_group_name = workspace.group_for_policy(event.old_policy)
    old_group = api.group.get(old_group_name)
    for member in old_group.getAllGroupMembers():
        groups = workspace.get(member.getId()).groups
        groups -= set([event.old_policy.title()])
        groups.add(event.new_policy.title())
Exemple #4
0
    def user_search_results(self):
        """ Add [member] to a user title if user is a member
        of current workspace
        """
        results = super(SharingView, self).user_search_results()
        ws = IWorkspace(self.context)
        roles_mapping = ws.available_groups
        roles = roles_mapping.get(self.context.participant_policy.title())

        for result in results:
            if result["id"] in ws.members:
                groups = ws.get(result["id"]).groups
                for role in roles:
                    result["roles"][role] = "acquired"
                if "Admins" in groups:
                    title = "administrator"
                    result["roles"]["TeamManager"] = "acquired"
                else:
                    title = "member"
                result["title"] = "%s [%s]" % (result["title"], title)

        return results
Exemple #5
0
    def user_search_results(self):
        """ Add [member] to a user title if user is a member
        of current workspace
        """
        results = super(SharingView, self).user_search_results()
        ws = IWorkspace(self.context)
        roles_mapping = ws.available_groups
        roles = roles_mapping.get(self.context.participant_policy.title())

        for result in results:
            if result["id"] in ws.members:
                groups = ws.get(result["id"]).groups
                for role in roles:
                    result["roles"][role] = "acquired"
                if "Admins" in groups:
                    title = "administrator"
                    result["roles"]["TeamManager"] = "acquired"
                else:
                    title = "member"
                result["title"] = "%s [%s]" % (result["title"], title)

        return results