예제 #1
0
파일: views.py 프로젝트: 4416/hazel-cms
def edit(request, key):
    layout = Layout.get(db.Key(key))
    form = LayoutForm(request.form, obj=layout)
    if request.method == "POST" and form.validate():
        form.auto_populate(layout)
        layout.put()
        # clear depending caches
        for node in layout.get_affected_nodes():
            node.invalidate_cache()
        if form.save.data is True:
            return redirect(url_for('nut:layouts/list'), 301)
    return render_template('app:layouts/form.html', form=form, layout=layout)
예제 #2
0
파일: views.py 프로젝트: 4416/hazel-cms
def add(request, key):
    form = LayoutForm(request.form)
    if request.method == 'POST' and form.validate():
        layout = Layout.add(to=key, type=LAYOUT,
                            name=form.name.data,
                            slug=slugify(form.name.data),
                            body=form.body.data,
                            author=users.get_current_user())
        layout.update_extends()
        layout.put()
        if form.save.data is True:
            return redirect(url_for('nut:layouts/list'), 301)
        if form.cont.data is True:
            return redirect(url_for('nut:layouts/edit', key=layout.get_key()), 301)
    return render_template('app:layouts/form.html', form=form)