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)
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)
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)