示例#1
0
def create(collection_id):
    collection = obj_or_404(Collection.by_id(collection_id))
    authz.require(authz.collection_write(collection.id))
    network = Network.create(request_data(), collection, request.auth_role)
    db.session.commit()
    log_event(request)
    return view(collection_id, network.id)
示例#2
0
def delete(collection_id, id):
    collection = obj_or_404(Collection.by_id(collection_id))
    authz.require(authz.collection_write(collection.id))
    network = obj_or_404(Network.by_id_collection(id, collection))
    network.delete()
    db.session.commit()
    log_event(request)
    return jsonify({'status': 'ok'})
示例#3
0
def update(collection_id, id):
    collection = obj_or_404(Collection.by_id(collection_id))
    authz.require(authz.collection_write(collection_id))
    network = obj_or_404(Network.by_id_collection(id, collection))
    network.update(request_data())
    log_event(request)
    db.session.commit()
    return view(collection_id, network.id)
示例#4
0
def view(collection_id, id):
    collection = obj_or_404(Collection.by_id(collection_id))
    authz.require(authz.collection_read(collection_id))
    network = obj_or_404(Network.by_id_collection(id, collection))
    return jsonify(network)
示例#5
0
def index(collection_id):
    collection = obj_or_404(Collection.by_id(collection_id))
    authz.require(authz.collection_read(collection.id))
    q = Network.all()
    q = q.filter(Network.collection_id == collection.id)
    return jsonify(Pager(q, collection_id=collection.id))