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)
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'})
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)
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)
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))