コード例 #1
0
ファイル: api.py プロジェクト: dougaitken/discograph
def route__api__entity_type__network__entity_id(entity_type, entity_id):
    if entity_type not in ("artist", "label"):
        raise exceptions.APIError(message="Bad Entity Type", status_code=404)
    parsed_args = helpers.parse_request_args(request.args)
    original_roles, original_year = parsed_args
    on_mobile = request.MOBILE
    data = helpers.get_network(entity_id, entity_type, on_mobile=on_mobile, cache=True, roles=original_roles)
    if data is None:
        raise exceptions.APIError(message="No Data", status_code=400)
    return jsonify(data)
コード例 #2
0
def route__entity_type__entity_id(entity_type, entity_id):
    import discograph
    app = current_app._get_current_object()
    parsed_args = helpers.parse_request_args(request.args)
    original_roles, original_year = parsed_args
    if not original_roles:
        original_roles = default_roles
    if entity_type not in ('artist', 'label'):
        raise exceptions.APIError(message='Bad Entity Type', status_code=404)
    on_mobile = request.MOBILE
    data = helpers.get_network(
        entity_id,
        entity_type,
        on_mobile=on_mobile,
        cache=True,
        roles=original_roles,
    )
    if data is None:
        raise exceptions.APIError(message='No Data', status_code=500)
    initial_json = json.dumps(
        data,
        sort_keys=True,
        indent=4,
        separators=(',', ': '),
    )
    initial_json = 'var dgData = {};'.format(initial_json)
    entity_name = data['center']['name']
    is_a_return_visitor = request.cookies.get('is_a_return_visitor')
    key = '{}-{}'.format(entity_type, entity_id)
    #url = '/{}/{}'.format(entity_type, entity_id)
    url = url_for(
        request.endpoint,
        entity_type=entity_type,
        entity_id=entity_id,
        roles=original_roles,
    )
    title = 'Disco/graph: {}'.format(entity_name)
    multiselect_mapping = discograph.CreditRole.get_multiselect_mapping()
    rendered_template = render_template(
        'index.html',
        application_url=app.config['APPLICATION_ROOT'],
        initial_json=initial_json,
        is_a_return_visitor=is_a_return_visitor,
        key=key,
        multiselect_mapping=multiselect_mapping,
        og_title='Disco/graph: The "{}" network'.format(entity_name),
        og_url=url,
        on_mobile=on_mobile,
        original_roles=original_roles,
        original_year=original_year,
        title=title,
    )
    response = make_response(rendered_template)
    response.set_cookie('is_a_return_visitor', 'true')
    return response
コード例 #3
0
ファイル: ui.py プロジェクト: digideskio/discograph
def route__entity_type__entity_id(entity_type, entity_id):
    import discograph
    app = current_app._get_current_object()
    parsed_args = helpers.parse_request_args(request.args)
    original_roles, original_year = parsed_args
    if not original_roles:
        original_roles = default_roles
    if entity_type not in ('artist', 'label'):
        raise exceptions.APIError(message='Bad Entity Type', status_code=404)
    on_mobile = request.MOBILE
    data = helpers.get_network(
        entity_id,
        entity_type,
        on_mobile=on_mobile,
        cache=True,
        roles=original_roles,
        )
    if data is None:
        raise exceptions.APIError(message='No Data', status_code=500)
    initial_json = json.dumps(
        data,
        sort_keys=True,
        indent=4,
        separators=(',', ': '),
        )
    initial_json = 'var dgData = {};'.format(initial_json)
    entity_name = data['center']['name']
    is_a_return_visitor = request.cookies.get('is_a_return_visitor')
    key = '{}-{}'.format(entity_type, entity_id)
    #url = '/{}/{}'.format(entity_type, entity_id)
    url = url_for(
        request.endpoint,
        entity_type=entity_type,
        entity_id=entity_id,
        roles=original_roles,
        )
    title = 'Disco/graph: {}'.format(entity_name)
    multiselect_mapping = discograph.CreditRole.get_multiselect_mapping()
    rendered_template = render_template(
        'index.html',
        application_url=app.config['APPLICATION_ROOT'],
        initial_json=initial_json,
        is_a_return_visitor=is_a_return_visitor,
        key=key,
        multiselect_mapping=multiselect_mapping,
        og_title='Disco/graph: The "{}" network'.format(entity_name),
        og_url=url,
        on_mobile=on_mobile,
        original_roles=original_roles,
        original_year=original_year,
        title=title,
        )
    response = make_response(rendered_template)
    response.set_cookie('is_a_return_visitor', 'true')
    return response
コード例 #4
0
ファイル: api.py プロジェクト: shmiko/discograph
def route__api__entity_type__network__entity_id(entity_type, entity_id):
    if entity_type not in ('artist', 'label'):
        raise exceptions.APIError(message='Bad Entity Type', status_code=404)
    on_mobile = request.MOBILE
    data = helpers.get_network(
        entity_id,
        entity_type,
        on_mobile=on_mobile,
        cache=True,
        )
    if data is None:
        raise exceptions.APIError(message='No Data', status_code=400)
    return jsonify(data)
コード例 #5
0
def route__api__entity_type__network__entity_id(entity_type, entity_id):
    if entity_type not in ('artist', 'label'):
        raise exceptions.APIError(message='Bad Entity Type', status_code=404)
    parsed_args = helpers.parse_request_args(request.args)
    original_roles, original_year = parsed_args
    on_mobile = request.MOBILE
    data = helpers.get_network(
        entity_id,
        entity_type,
        on_mobile=on_mobile,
        cache=True,
        roles=original_roles,
    )
    if data is None:
        raise exceptions.APIError(message='No Data', status_code=400)
    return jsonify(data)