示例#1
0
def reply(index,user_name):
    form = CommentForm()
    if form.validate_on_submit():
        comment = Comment(content=form.content.data)
        comment.user_id = g.user.id
        comment.article_id = index  #
        # comment.reply_type = 2
        comment.to_user = user_name
        db.session.add(comment)
        db.session.commit()
        flash('Submit reply successfully.')
        return redirect(url_for('detail', index=index))
    return render_template('reply.html', title='Reply', form=form)
示例#2
0
文件: views.py 项目: dhacks/team-h
def post_comment(post_id):
    """
    本文表示、個別ページ post_idから対応するPOSTのデータをDBからとって表示
    本文したにコメント表示
    """
    form = CommentForm()
    if form.validate_on_submit():
        comment = Comment(author=current_user, post_on=datetime.now(), body=form.body.data, post_id=post_id)
        db.session.add(comment)
        db.session.commit()
        print("comment post success")
        return redirect("/{:d}".format(post_id))
    return render_template("editor.html", form=form)
示例#3
0
def post_comment(post_id):
    """
    本文表示、個別ページ post_idから対応するPOSTのデータをDBからとって表示
    本文したにコメント表示
    """
    form = CommentForm()
    if form.validate_on_submit():
        comment = Comment(author=current_user,
                          post_on=datetime.now(),
                          body=form.body.data,
                          post_id=post_id)
        db.session.add(comment)
        db.session.commit()
        print("comment post success")
        return redirect('/{:d}'.format(post_id))
    return render_template('editor.html', form=form)