예제 #1
0
def add_path(parent_id, path_name):
    path = m.Path.query.get(parent_id)

    new_path = m.Path()
    new_path.text = path_name
    new_path.book_id = path.book_id

    m.db.session.add(new_path)
    m.db.session.commit()

    path.children.append(new_path)
    m.db.session.commit()

    return m.PathSchemaRoot().dump(new_path)
예제 #2
0
def end_path(id):
    path = m.Path.query.get(id)
    path.icon = 'fas fa-file'
    m.db.session.commit()
    return m.PathSchemaRoot().dump(path)
예제 #3
0
def rename_path(id, name):
    path = m.Path.query.get(id)
    path.text = name
    m.db.session.commit()
    return m.PathSchemaRoot().dump(path)
예제 #4
0
def delete_path(id):
    path = m.Path.query.get(id)
    path.old_parent = path.__dict__['parent']
    path.parent = None
    m.db.session.commit()
    return m.PathSchemaRoot().dump(path)
예제 #5
0
def get_tree(book_id):
    path = m.Path.query.filter(m.Book.id == book_id) \
        .first()
    return m.PathSchemaRoot().dump(path)