Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def delete_comment(id):
- comment = Comment.query.get_or_404(id)
- post = Post.query.get_or_404(comment.post_id)
- if comment.user != current_user and post.author != current_user:
- abort(403)
- db.session.delete(comment)
- db.session.commit()
- flash('The comment has been deleted!', 'success')
- return redirect(url_for('main.home'))
Add Comment
Please, Sign In to add comment