Example #1
0
def blog_post_new():
    f = BlogPostForm()
    # if request.method == "POST" and f.validate():
    if request.method == "POST":
        post = BlogPost.populate_from_ui(f)
        post.save()
        return redirect(url_for('.blog_post_list'))
    title = "Create new post"
    return render_template("admin/blog/detail.html", v={
        "title": title,
        "f": f,
        "action": ""
    })
Example #2
0
def blog_post_update(post_id):
    if request.method == "POST":
        f = BlogPostForm()
        post = BlogPost.populate_from_ui(f)
        post.update()
        return redirect(url_for('.blog_post_list'))
    else:
        post = BlogPost.populate_from_db(BlogPostHeader.query.get(post_id))
        title = u"Update {0}".format(post.name)
        f = BlogPostForm(obj=post)

        return render_template("admin/blog/detail.html", v={
            "title": title,
            "f": f,
            "action": ""
        })