def new_post(): form = PostForm() if form.validate_on_submit(): post = Post() form.populate_obj(post) post.put() return redirect(url_for('admin.blog.index')) return render_template( 'blog/admin/post_new.html', form=form )
def edit_post(key_id): post = Post.retrieve_by_id(key_id) if not post: return redirect(url_for('admin.blog.index')) if request.method == 'POST' and 'delete_post' in request.form: post.key.delete() return redirect(url_for('admin.blog.index')) form = PostForm(obj=post) if form.validate_on_submit(): form.populate_obj(post) post.put() return redirect(url_for('admin.blog.index')) return render_template( 'blog/admin/post_edit.html', form=form, post=post )