Пример #1
0
def status():
    return jsonify({
        'logged_in': authz.logged_in(),
        'api_key': request.account.api_key if authz.logged_in() else None,
        'account': request.account,
        'base_url': url_for('index', _external=True)
    })
Пример #2
0
def status():
    return jsonify(
        {
            "logged_in": authz.logged_in(),
            "api_key": request.account.api_key if authz.logged_in() else None,
            "account": request.account,
            "base_url": url_for("index", _external=True),
        }
    )
Пример #3
0
def status():
    return jsonify({
        'logged_in':
        authz.logged_in(),
        'api_key':
        request.account.api_key if authz.logged_in() else None,
        'account':
        request.account,
        'base_url':
        url_for('index', _external=True)
    })
Пример #4
0
def lookup(dataset):
    dataset = Dataset.find(dataset)
    readonly = validators.StringBool(if_empty=False, if_missing=False)\
            .to_python(request.args.get('readonly'))
    readonly = readonly if authz.logged_in() else True
    data = request_content()
    if response_format() != 'json':
        return Response("Not implemented!", status=400)

    try:
        alias = Alias.lookup(dataset, data, request.account,
                             readonly=readonly)
        if alias is None:
            return jsonify({
                'is_matched': False,
                'entity': None,
                'name': data.get('name'),
                'dataset': dataset.name
                }, status=404)

        if isinstance(alias, Entity):
            return jsonify({
                'is_matched': True,
                'entity': alias,
                'name': data.get('name'),
                'dataset': dataset.name
                }, status=200)

        db.session.commit()
        status = 200 if alias.is_matched else 404
        status = 418 if alias.is_invalid else status
        return jsonify(alias, status=status)
    except Invalid, inv:
        return handle_invalid(inv, index, data=data,
                              args=[dataset.name])
Пример #5
0
def lookup(dataset):
    dataset = Dataset.find(dataset)
    readonly = validators.StringBool(if_empty=False, if_missing=False)\
            .to_python(request.args.get('readonly'))
    readonly = readonly if authz.logged_in() else True
    data = request_content()
    if response_format() != 'json':
        return Response("Not implemented!", status=400)

    try:
        link = Link.lookup(dataset, data, request.account,
                           readonly=readonly)
        if link is None:
            return jsonify({
                'is_matched': False,
                'value': None,
                'key': data.get('key'),
                'dataset': dataset.name
                }, status=404)

        if isinstance(link, Value):
            add_candidate_to_cache(dataset, data.get('key'), link.id)
            return jsonify({
                'is_matched': True,
                'value': link,
                'key': data.get('key'),
                'dataset': dataset.name
                }, status=200)

        if link.value:
            add_candidate_to_cache(dataset, link.key, link.value.id)

        db.session.commit()
        status = 200 if link.is_matched else 404
        status = 418 if link.is_invalid else status
        return jsonify(link, status=status)
    except Invalid, inv:
        return handle_invalid(inv, index, data=data,
                              args=[dataset.name])
Пример #6
0
def lookup(dataset):
    dataset = Dataset.find(dataset)
    readonly = validators.StringBool(if_empty=False, if_missing=False)\
            .to_python(request.args.get('readonly'))
    readonly = readonly if authz.logged_in() else True
    data = request_content()
    if response_format() != 'json':
        return Response("Not implemented!", status=400)

    try:
        alias = Alias.lookup(dataset, data, request.account, readonly=readonly)
        if alias is None:
            return jsonify(
                {
                    'is_matched': False,
                    'entity': None,
                    'name': data.get('name'),
                    'dataset': dataset.name
                },
                status=404)

        if isinstance(alias, Entity):
            return jsonify(
                {
                    'is_matched': True,
                    'entity': alias,
                    'name': data.get('name'),
                    'dataset': dataset.name
                },
                status=200)

        db.session.commit()
        status = 200 if alias.is_matched else 404
        status = 418 if alias.is_invalid else status
        return jsonify(alias, status=status)
    except Invalid, inv:
        return handle_invalid(inv, index, data=data, args=[dataset.name])
Пример #7
0
def logout():
    authz.require(authz.logged_in())
    session.clear()
    #flash("You've been logged out.", "success")
    return redirect(url_for('index'))
Пример #8
0
def status():
    return jsonify({
        'logged_in': authz.logged_in(),
        'api_key': request.account.api_key if authz.logged_in() else None,
        'account': request.account
    })
Пример #9
0
def logout():
    authz.require(authz.logged_in())
    session.clear()
    return redirect('/')
Пример #10
0
def logout():
    authz.require(authz.logged_in())
    session.clear()
    return redirect('/')
Пример #11
0
def account():
    authz.require(authz.logged_in())
    return render_template("account.html", api_key=request.account.api_key)
Пример #12
0
def logout():
    authz.require(authz.logged_in())
    session.clear()
    flash("You've been logged out.", "success")
    return redirect(url_for('index'))
Пример #13
0
def account():
    authz.require(authz.logged_in())
    return render_template('account.html', api_key=request.account.api_key)