Advertisement
OlexBy

ddssdsd

May 20th, 2015
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. @comments_bp.route('/comments/<int:comment_id>/', methods=['DELETE'])
  2. def delete_comment(comment_id):
  3. comment_query = db.session.query(Comment)
  4. comment_filtered = comment_query.filter(Comment.id == comment_id)
  5. if not comment_filtered:
  6. return jsonify({'msg': 'comment not found', 'status': 1})
  7. has_permission = g.user.is_superuser or g.user.id == Comment.id
  8. if has_permission:
  9. comment_filtered.delete()
  10. db.session.commit()
  11. return jsonify({'status': 0})
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement