Ejemplo n.º 1
0
def groups(request):
    """Retrieve the groups for this request's user."""

    expand = request.GET.getall("expand") or []
    list_svc = request.find_service(name="group_list")

    all_groups = list_svc.request_groups(
        user=request.user,
        authority=request.params.get("authority"),
        document_uri=request.params.get("document_uri"),
    )
    all_groups = [GroupContext(group, request) for group in all_groups]
    all_groups = GroupsJSONPresenter(all_groups).asdicts(expand=expand)
    return all_groups
Ejemplo n.º 2
0
def profile_groups(request):
    """
    Retrieve the groups for this request's user.

    Retrieve all groups for which the request's user is a member, regardless
    of type. Groups are sorted by (name, pubid).
    """

    expand = request.GET.getall("expand") or []
    list_svc = request.find_service(name="group_list")

    groups = list_svc.user_groups(user=request.user)
    group_contexts = [GroupContext(group, request) for group in groups]
    groups_formatted = GroupsJSONPresenter(group_contexts).asdicts(expand=expand)
    return groups_formatted
Ejemplo n.º 3
0
def groups(request):
    authority = request.params.get('authority')
    document_uri = request.params.get('document_uri')
    list_svc = request.find_service(name='list_groups')
    links_svc = request.find_service(name='group_links')

    if request.user is not None:
        authority = request.user.authority
    else:
        authority = authority or request.authority
    all_groups = list_svc.request_groups(user=request.user,
                                         authority=authority,
                                         document_uri=document_uri)

    all_groups = GroupsJSONPresenter(all_groups, links_svc).asdicts()
    return all_groups
Ejemplo n.º 4
0
def groups(request):
    authority = request.params.get('authority')
    document_uri = request.params.get('document_uri')
    expand = request.GET.getall('expand') or []

    list_svc = request.find_service(name='list_groups')

    if request.user is not None:
        authority = request.user.authority
    else:
        authority = authority or request.authority
    all_groups = list_svc.request_groups(user=request.user,
                                         authority=authority,
                                         document_uri=document_uri)
    all_groups = [GroupContext(group, request) for group in all_groups]
    all_groups = GroupsJSONPresenter(all_groups).asdicts(expand=expand)
    return all_groups
Ejemplo n.º 5
0
def groups(request):
    """Retrieve the groups for this request's user."""

    authority = request.params.get("authority")
    document_uri = request.params.get("document_uri")
    expand = request.GET.getall("expand") or []

    list_svc = request.find_service(name="list_groups")

    if request.user is not None:
        authority = request.user.authority
    else:
        authority = authority or request.default_authority
    all_groups = list_svc.request_groups(
        user=request.user, authority=authority, document_uri=document_uri
    )
    all_groups = [GroupContext(group, request) for group in all_groups]
    all_groups = GroupsJSONPresenter(all_groups).asdicts(expand=expand)
    return all_groups
Ejemplo n.º 6
0
def groups(request):
    authority = request.params.get('authority')
    document_uri = request.params.get('document_uri')
    svc = request.find_service(name='list_groups')

    if request.feature('filter_groups_by_scope'):
        # Filter open groups by scope against the ``document_uri`` param.
        # The different handling of authority here is part of this
        # feature — authority "babysitting" is going to be moving
        # out of the service and back to the view's...purview.
        if request.user is not None:
            authority = request.user.authority
        else:
            authority = authority or request.authority
        all_groups = svc.request_groups(user=request.user,
                                        authority=authority,
                                        document_uri=document_uri)
    else:
        all_groups = svc.all_groups(user=request.user,
                                    authority=authority,
                                    document_uri=document_uri)
    all_groups = GroupsJSONPresenter(all_groups, request.route_url).asdicts()
    return all_groups