Advertisement
OlexBy

dddddddddddd

May 20th, 2015
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 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. has_permission = g.user.is_superuser
  6. if has_permission:
  7. result = comment_filtered.delete()
  8. if result:
  9. db.session.commit()
  10. return jsonify({'status': 0})
  11. else:
  12. db.session.rollback()
  13. return jsonify({'msg': 'comment not found', 'status': 1})
  14. else:
  15. return jsonify({'status': 2}), 405
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement