def recomment(comment): form = NewCommentForm() comment = Comment.query.filter_by(id=comment).first() if form.validate_on_submit(): content = form.comment.data recomment = ReComment(content=content, comment_id=comment.id, user_id=current_user.id) db.session.add(recomment) db.session.commit() flash("cevap eklendi", "success") return redirect(url_for("show_article", article=comment.topost.id))
def show_article(article): post = Post.query.filter_by(id=article).first_or_404() form = NewCommentForm() if form.validate_on_submit(): content = form.comment.data comment = Comment(content=content, post_id=post.id, user_id=current_user.id) db.session.add(comment) db.session.commit() flash('Comment added', 'success') return redirect(url_for('show_article', article=post.id)) comments = Comment.query.filter_by(post_id=post.id).all() recomments = ReComment.query.all() return render_template("public/article.html", post=post, comments=comments, form=form, recomments=recomments)