Beispiel #1
0
def add_blog_post():
    form = PostForm()

    if form.validate_on_submit():
        post = BlogPost()

        post.slug = form.slug.data
        post.title = form.title.data
        post.content = form.content.data
        post.published_on = form.published_on.data
        post.user_id = current_user.id
        post.created_on = datetime.utcnow()
        post.blogcategory_id = form.category.data
        post.blogpoststatus_id = form.status.data

        db.session.add(post)
        flash('"{0}" has been saved'.format(post.title))

        return redirect(url_for('.blog_posts'))

    return render_template('admin/blog/posts/add_post.html', js='posts/add_post', form=form)