Ejemplo n.º 1
0
def update_concept(id_):
    data = request.json
    c = Concept.get_node(id_)
    c.name = data['name']
    c.brief = data['brief']
    c.content = data['content']
    return jsonify(build_nodes(Concept.upsert(c)))
Ejemplo n.º 2
0
def add_concept():
    data = request.json
    c = Concept()
    c.name = data['name']
    c.brief = data['brief']
    c.content = data['content']
    c.label = g.label
    if data['source_id']:
        from_ = Concept.get_node(data['source_id'])
        from_.relates.add(c)
        from_.label = g.label
        return jsonify(build_nodes(Concept.upsert(from_)))
    return jsonify(build_nodes(Concept.upsert(c)))
Ejemplo n.º 3
0
def get_list():
    concepts = Concept.get_list(g.label)
    nodes = []
    edges = []

    for concept in concepts:
        nodes.append(build_nodes(concept))
        edges += build_edges(concept)

    return jsonify(elements={"nodes": nodes, "edges": edges})
Ejemplo n.º 4
0
def del_relations():
    from_ = Concept.get_node(request.args.get('source_id'))
    to = Concept.get_node(request.args.get('target_id'))
    from_.relates.remove(to)
    return jsonify(build_nodes(Concept.upsert(from_)))
Ejemplo n.º 5
0
def del_concept(id_):
    return jsonify(Concept.delete(id_))
Ejemplo n.º 6
0
def get_concepts(id_):
    return jsonify(Concept.get_node(id_))