Beispiel #1
0
def init_user_node(user, username):
    node = Node()
    node.name = username + u'的知识库'
    node.type = 'libeary'
    node.owner = user
    node.is_publish = False
    db.session.add(node)
    db.session.commit()
Beispiel #2
0
def create_node():
    data = request.get_json(force=True)
    node = Node()
    node.parent = data['parent']
    node.name = data['text']
    node.type = data['type']
    node.owner_id = g.user.id
    db.session.add(node)
    db.session.flush()
    if node.type == 'file':
        note = Block()
        note.node_id = node.id
        note.content = ""
        db.session.add(note)
    db.session.commit()
    return jsonify({
        'id': node.id,
        'text': node.name,
        'type': node.type
    })