예제 #1
0
파일: post.py 프로젝트: ap13p/elearn
def post_update(post_id):
    post = Post.get(Post.id == post_id)
    form = PostForm(request.form, obj=post)
    form.action = url_for('admin:post:update', post_id=post_id)
    if form.validate_on_submit():
        form.populate_obj(post)
        post.save()
        flash('Sukses memperbarui posting')
        return redirect(url_for('admin:post:list'))
    return render_template('admin/post/update.html', form=form)
예제 #2
0
파일: post.py 프로젝트: ap13p/elearn
def post_create():
    form = PostForm(request.form)
    form.action = url_for('admin:post:create')
    if form.validate_on_submit():
        post = Post()
        form.populate_obj(post)
        post.publik = form.publik.data or False
        post.author = g.user
        post.save()
        flash('Sukses membuat posting baru')
        return redirect(url_for('admin:post:list'))
    return render_template('admin/post/create.html', form=form)