Example #1
0
def list(request):
    files = dict([(f.get_key(), f) for f in File.all()])
    root = None
    for file in files:
        file = files[file]
        if file.path == '0':
            root = file
            break
    if root is not None:
        root = rec(root, files)
    return render_template('app:files/list.html', root=root)
Example #2
0
def list_pages(request):
    nodes = dict([(n.get_key(), n) for n in Node.all()])
    root = None
    for node in nodes:
        node = nodes[node]
        if node.path == '0':
            root = node
            break
    if root is not None:
        root = rec(root, nodes)
    return render_template('app:pages/list.html', root=root)
Example #3
0
def delete(request, key):
    form = FileConfirmDeleteForm(request.form)
    if request.method == "POST" and form.validate():
        if form.drop.data is True:
            File.drop(key)
            return redirect(url_for('nut:files/list'), 301)
        if form.cascade.data is True:
            File.drop(key, cascade=True)
            return redirect(url_for('nut:files/list'), 301)
    file = File.get(key)
    files = dict([(n.get_key(), n) for n in File.all().filter("ancestors = ", key)])
    file = rec(file, files)

    return render_template('app:files/confirm_delete.html', file=file, form=form)
Example #4
0
def delete(request, key):
    form = ConfirmDeleteForm(request.form)
    if request.method == 'POST' and form.validate():
        if form.drop.data is True:
            node = Node.get(key)
            db.delete(node.blocks)
            Node.drop(key)
            return redirect('/admin/pages/', 301)
        if form.cascade.data is True:
            # cascade callback
            # inject a cascade callback that does
            #            # try to delete the key
            #            for i in range(2):
            #                if memcache.delete(node.get_absolute_url()) > 0:
            #                    break
            Node.drop(key, cascade=True)
            # FIXME: remove blocks from dropped Nodes
            return redirect(url_for('nut:pages/list_pages'), 301)

    node = Node.get(key)
    nodes = dict([(n.get_key(), n) for n in Node.all().filter("ancestors = ", key)])
    node = rec(node, nodes)
    return render_template('app:pages/confirm_delete.html', form=form,
                           node=node)