예제 #1
0
파일: pages.py 프로젝트: alsaihn/flask-blog
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")
예제 #2
0
파일: pages.py 프로젝트: alsaihn/flask-blog
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)