Esempio n. 1
0
def index():
    form = PostForm()
    if form.validate_on_submit():
        post = Post(title=form.title.data, content=form.content.data, author_id="Lewis")
        db.session.add(post)
        db.session.commit()
        flash(("Posting success"), "success")
        return redirect(url_for('frontend.index'))

    return render_template("admin.html", form=form)
Esempio n. 2
0
File: post.py Progetto: lewisc402/bg
def newpost():
    form = PostForm()
    if form.validate_on_submit():
        post = Post(title=form.title.data, content=form.content.data, author_id=
                g.identity.id)
        db.session.add(post)
        db.session.commit()

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

        return redirect(url_for('post.view', post_id=post.id))
    return render_template("newpost.html", form=form)
Esempio n. 3
0
File: post.py Progetto: lewisc402/bg
def edit(post_id):
    post = Post.query.get_or_404(post_id)

    form = PostForm(title = post.title,
                    content = post.content)
                    #obj = post)

    if form.validate_on_submit():
        form.populate_obj(post)
        db.session.add(post)
        db.session.commit()
        flash(("Post has been changed"), "success")
        return redirect(url_for('post.view', post_id=post.id))

    return render_template("newpost.html", form=form)