Beispiel #1
0
def single(request):

    searchParams = dict(request.GET._iterlists())
    if searchParams.get('defaults'):
        searchParams['inTitle'] = 'true'
        searchParams['sort'] = 'date'

    url, params, headers = Search.build_request(
        request.get_host(),
        params=searchParams,
        access_token=request.access_token)
    request.view_requests.append(
        grequests.get(url, params=params, headers=headers))

    try:
        responses = response_list_to_dict(grequests.map(request.view_requests))
    except APIException as exc:
        return respond_with_error(request, exc)
    search = Search.from_api_response(responses[url])

    view_data = {
        'user':
        Profile(responses[request.whoami_url], summary=False)
        if request.whoami_url else None,
        'site':
        Site(responses[request.site_url]),
        'content':
        search,
    }

    if responses[url].get('results'):
        view_data['pagination'] = build_pagination_links(
            responses[url]['results']['links'], search.results)

    return render(request, single_template, view_data)
Beispiel #2
0
def single(request):

    searchParams = request.GET.dict()
    searchParams['type'] = ['conversation','event','profile','huddle']
    searchParams['since'] = -1

    url, params, headers = Search.build_request(request.get_host(), params=searchParams,
        access_token=request.access_token)
    request.view_requests.append(grequests.get(url, params=params, headers=headers))

    try:
        responses = response_list_to_dict(grequests.map(request.view_requests))
    except APIException as exc:
        return respond_with_error(request, exc)
    search = Search.from_api_response(responses[url])

    view_data = {
        'user': Profile(responses[request.whoami_url], summary=False) if request.whoami_url else None,
        'site': Site(responses[request.site_url]),
        'content': search,
        'site_section': 'today'
    }

    if responses[url].get('results'):
        view_data['pagination'] = build_pagination_links(
                    responses[url]['results']['links'],
                    search.results
                )

    return render(request, single_template, view_data)
Beispiel #3
0
def single(request):

    searchParams = dict(request.GET._iterlists())
    if searchParams.get('defaults'):
        searchParams['inTitle'] = 'true'
        searchParams['sort'] = 'date'

    url, params, headers = Search.build_request(request.get_host(), params=searchParams,
        access_token=request.access_token)
    request.view_requests.append(grequests.get(url, params=params, headers=headers))

    try:
        responses = response_list_to_dict(grequests.map(request.view_requests))
    except APIException as exc:
        return respond_with_error(request, exc)
    search = Search.from_api_response(responses[url])

    view_data = {
        'user': Profile(responses[request.whoami_url], summary=False) if request.whoami_url else None,
        'site': Site(responses[request.site_url]),
        'content': search,
    }

    if responses[url].get('results'):
        view_data['pagination'] = build_pagination_links(responses[url]['results']['links'], search.results)

    return render(request, single_template, view_data)
Beispiel #4
0
def single(request, profile_id):
    """
    Display a single profile by ID.
    """

    # Fetch profile details.
    profile_url, params, headers = Profile.build_request(request.get_host(), profile_id, access_token=request.access_token)
    request.view_requests.append(grequests.get(profile_url, params=params, headers=headers))

    # Fetch items created by this profile.
    search_q = 'type:conversation type:event type:huddle type:comment authorId:%s' % profile_id
    search_params = {'limit': 10, 'q': search_q, 'sort': 'date'}
    search_url, params, headers = Search.build_request(request.get_host(), search_params,
        access_token=request.access_token)
    request.view_requests.append(grequests.get(search_url, params=params, headers=headers))

    try:
        responses = response_list_to_dict(grequests.map(request.view_requests))
    except APIException as exc:
        return respond_with_error(request, exc)

    user = Profile(responses[request.whoami_url], summary=False) if request.whoami_url else None
    profile = Profile(responses[profile_url], summary=False)

    view_data = {
        'user': user,
        'content': profile,
        'item_type': 'profile',
        'site': Site(responses[request.site_url]),
        'search': Search.from_api_response(responses[search_url]),
        'site_section': 'people'
    }
    return render(request, single_template, view_data)
Beispiel #5
0
def single(request, profile_id):
    """
    Display a single profile by ID.
    """

    # Fetch profile details.
    profile_url, params, headers = Profile.build_request(
        request.get_host(), profile_id, access_token=request.access_token)
    request.view_requests.append(
        grequests.get(profile_url, params=params, headers=headers))

    # Fetch items created by this profile.
    search_q = 'type:conversation type:event type:huddle type:comment authorId:%s' % profile_id
    search_params = {'limit': 10, 'q': search_q, 'sort': 'date'}
    search_url, params, headers = Search.build_request(
        request.get_host(), search_params, access_token=request.access_token)
    request.view_requests.append(
        grequests.get(search_url, params=params, headers=headers))

    try:
        responses = response_list_to_dict(grequests.map(request.view_requests))
    except APIException as exc:
        return respond_with_error(request, exc)

    user = Profile(responses[request.whoami_url],
                   summary=False) if request.whoami_url else None
    profile = Profile(responses[profile_url], summary=False)

    view_data = {
        'user': user,
        'content': profile,
        'item_type': 'profile',
        'site': Site(responses[request.site_url]),
        'search': Search.from_api_response(responses[search_url]),
        'site_section': 'people'
    }
    return render(request, single_template, view_data)
Beispiel #6
0
def single(request):

    searchParams = request.GET.dict()
    searchParams['type'] = ['conversation', 'event', 'profile', 'huddle']
    searchParams['since'] = -1

    url, params, headers = Search.build_request(
        request.get_host(),
        params=searchParams,
        access_token=request.access_token)
    request.view_requests.append(
        grequests.get(url, params=params, headers=headers))

    try:
        responses = response_list_to_dict(grequests.map(request.view_requests))
    except APIException as exc:
        return respond_with_error(request, exc)
    search = Search.from_api_response(responses[url])

    view_data = {
        'user':
        Profile(responses[request.whoami_url], summary=False)
        if request.whoami_url else None,
        'site':
        Site(responses[request.site_url]),
        'content':
        search,
        'site_section':
        'today'
    }

    if responses[url].get('results'):
        view_data['pagination'] = build_pagination_links(
            responses[url]['results']['links'], search.results)

    return render(request, single_template, view_data)