Esempio n. 1
0
def info_posts(posts_id):
    comments_form = CommentsForm()
    if request.method == 'POST' and comments_form.validate:
        comments_info = CommentsInfo()
        comments_form.populate_obj(comments_info)
        comments_info.posts_id = posts_id
        comments_info.user_id = current_user.id
        db.session.add(comments_info)
        db.session.commit()
        flash(u'回复成功。')

    info_posts = PostsInfo.query.filter_by(id=posts_id).first()
    list_comments = CommentsInfo.query.filter_by(posts_id=posts_id).all()
    return render_template('admin/posts_info.html', form=comments_form, info_posts=info_posts, list_comments=list_comments)
Esempio n. 2
0
def add_comments(posts_id=0):
    posts = None
    comments_form = CommentsForm()
    if request.method == 'POST' and comments_form.validate:
        comments_info = CommentsInfo()
        comments_form.populate_obj(comments_info)
        comments_info.user_id = current_user.id
        comments_info.posts_id = posts_id
        db.session.add(comments_info)
        db.session.commit()
    else:
        posts = PostsInfo.query.filter_by(id=posts_id).first()
        comments_form.posts_id = posts.id

    return render_template('vip/comments_add.html', form=comments_form, posts=posts)