Guest User

Untitled

a guest
Jan 21st, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 KB | None | 0 0
  1. def delete_comment(id):
  2. comment = Comment.query.get_or_404(id)
  3. post = Post.query.get_or_404(comment.post_id)
  4. if comment.user != current_user and post.author != current_user:
  5. abort(403)
  6. db.session.delete(comment)
  7. db.session.commit()
  8. flash('The comment has been deleted!', 'success')
  9.  
  10. return redirect(url_for('main.home'))
Add Comment
Please, Sign In to add comment