Exemplo n.º 1
0
def new():
    form = Page()
    if form.validate_on_submit():
        user = g.database.engine.get_user(session['user'])
        new_page = g.database.models.Page.from_form(form, user)
        g.database.engine.add_page(new_page)
        flash("Saved.")
        return redirect(url_for(".edit", name=new_page.name))
    return render_template("forms.jinja.html", form=form, page_name="Create new page")
Exemplo n.º 2
0
def edit(name):
    page = g.database.engine.get_page(name)
    if page:
        form = Page(obj=page)
        if form.validate_on_submit():
            user = g.database.engine.get_user(session['user'])
            edited_page = g.database.models.Page.from_form(form, user)
            g.database.engine.add_page(edited_page)
            flash("Saved.")
        return render_template("forms.jinja.html", form=form, page_name="Editing page '{0}'".format(page.title))
    abort(404)