Example #1
0
def submit():

    form = PostForm()

    if form.validate_on_submit():

        post = Post(author=g.user)
        form.populate_obj(post)

        db.session.add(post)
        db.session.commit()

        flash(_("Posting success"), "success")

        return redirect(post.url)

    return render_template("blog/submit.html", form=form)
Example #2
0
def submit():

    form = PostForm()

    if form.validate_on_submit():

        post = Post(author=g.user)
        form.populate_obj(post)

        db.session.add(post)
        db.session.commit()

        flash(_("Posting success"), "success")

        return redirect(post.url)

    return render_template("blog/submit.html", form=form)
Example #3
0
File: post.py Project: ajaxj/fkmv
def edit(post_id):

    post = Post.query.get_or_404(post_id)

    form = PostForm(title=post.title, slug=post.slug, content=post.content, tags=post.tags, obj=post)

    if form.validate_on_submit():

        form.populate_obj(post)

        db.session.commit()

        flash(_("Post has been changed"), "success")

        return redirect(post.url)

    return render_template("admin/submit.html", form=form)
Example #4
0
def edit(post_id):

    post = Post.query.get_or_404(post_id)

    form = PostForm(title=post.title,
                    slug=post.slug,
                    content=post.content,
                    tags=post.tags,
                    obj=post)

    if form.validate_on_submit():

        form.populate_obj(post)

        db.session.commit()

        flash(_("Post has been changed"), "success")

        return redirect(post.url)

    return render_template("blog/submit.html", form=form)