'Manage users, groups and repositories associated with a role.'

@web.expose
@web.require_admin
def manage_role_associations(self, trans, **kwd):

    role_id = kwd.get('id', None)
    role = repository_util.get_role_by_id(trans.app, role_id)
    repository_role_association = role.repositories[0]
    repository = repository_role_association.repository
    associations_dict = repository_util.handle_role_associations(trans.app, role, repository, **kwd)
    in_users = associations_dict.get('in_users', [])
    out_users = associations_dict.get('out_users', [])
    in_groups = associations_dict.get('in_groups', [])
    out_groups = associations_dict.get('out_groups', [])
    message = associations_dict.get('message', '')
    status = associations_dict.get('status', 'done')
    return trans.fill_template('/webapps/tool_shed/role/role.mako', in_admin_controller=True, repository=repository, role=role, in_users=in_users, out_users=out_users, in_groups=in_groups, out_groups=out_groups, message=message, status=status)
