예제 #1
0
파일: admin.py 프로젝트: lewisc402/bg
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)
예제 #2
0
파일: post.py 프로젝트: 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)
예제 #3
0
파일: post.py 프로젝트: 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)