Beispiel #1
0
def frame_view(context, request):
    # TODO unit tests
    # TODO documentation
    user = request.AUTHENTICATED_USER
    response_data = {
        'frame_html': context['frame.html'](),
        'user_id': user.getId(),
        'user_roles': user.getRolesInContext(context),
    }
    return json_response(response_data, request.RESPONSE)
Beispiel #2
0
    user_id = user.getId()
    if user_id is not None:
        # Get groups (Eionet Roles)
        sources = users_tool.getSources()
        if sources:
            try:
                from eea.usersdb.factories import agent_from_uf
            except ImportError, e:
                pass
            else:
                agent = agent_from_uf(sources[0].getUserFolder())
                ldap_roles = sorted(
                    agent.member_roles_info('user', user.getId(),
                                            ('description', )))
                for (role_id, attrs) in ldap_roles:
                    groups.append((role_id, attrs.get('description',
                                                      ('', ))[0]))

    response_data = {
        'frame_html': context['frame.html'](),
        'user_id': user.getId(),
        'user_roles': user.getRolesInContext(context),
        'user_first_name': first_name,
        'user_last_name': last_name,
        'email': email,
        'user_phone_number': phone_number,
        'groups': groups
    }
    return json_response(response_data, request.RESPONSE)
        email = user_ob.email
    except:
        pass

    user_id = user.getId()
    if user_id is not None:
        # Get groups (Eionet Roles)
        sources = users_tool.getSources()
        if sources:
            try:
                from eea.usersdb.factories import agent_from_uf
            except ImportError, e:
                pass
            else:
                agent = agent_from_uf(sources[0].getUserFolder())
                ldap_roles = sorted(agent.member_roles_info("user", user.getId(), ("description",)))
                for (role_id, attrs) in ldap_roles:
                    groups.append((role_id, attrs.get("description", ("",))[0]))

    response_data = {
        "frame_html": context["frame.html"](),
        "user_id": user.getId(),
        "user_roles": user.getRolesInContext(context),
        "user_first_name": first_name,
        "user_last_name": last_name,
        "email": email,
        "user_phone_number": phone_number,
        "groups": groups,
    }
    return json_response(response_data, request.RESPONSE)