예제 #1
0
def update(slug, name):
    """ Update the data of the entity. """
    network, query = _get_query(slug, name)
    require.query.update(network, query)
    context = ValidationContext(network=network, query=query)
    data = dict(request_content(request).items())
    data = validate_query(dict(data.items()), context)
    query.update(data)
    db.session.commit()
    return jsonify(query, status=202)
예제 #2
0
def update(slug, name):
    """ Update the data of the entity. """
    network, query = _get_query(slug, name)
    require.query.update(network, query)
    context = ValidationContext(network=network, query=query)
    data = dict(request_content(request).items())
    data = validate_query(dict(data.items()), context)
    query.update(data)
    db.session.commit()
    return jsonify(query, status=202)
예제 #3
0
def create(slug):
    """ Create a new query. """
    network = _get_network(slug)
    require.query.create(network)
    data = request_content(request)
    context = ValidationContext(network=network)
    data = validate_query(dict(data.items()), context)
    query = Query.create(network, data)
    db.session.commit()
    url = url_for('.get', slug=network.slug, name=query.name)
    return jsonify(query, status=201, headers={'location': url})
예제 #4
0
def create(slug):
    """ Create a new query. """
    network = _get_network(slug)
    require.query.create(network)
    data = request_content(request)
    context = ValidationContext(network=network)
    data = validate_query(dict(data.items()), context)
    query = Query.create(network, data)
    db.session.commit()
    url = url_for('.get', slug=network.slug, name=query.name)
    return jsonify(query, status=201, headers={'location': url})