Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @comments_bp.route('/comments/<int:comment_id>/', methods=['DELETE'])
- def delete_comment(comment_id):
- comment_query = db.session.query(Comment)
- comment_filtered = comment_query.filter(Comment.id == comment_id)
- has_permission = g.user.is_superuser
- if has_permission:
- result = comment_filtered.delete()
- if result:
- db.session.commit()
- return jsonify({'status': 0})
- else:
- db.session.rollback()
- return jsonify({'msg': 'comment not found', 'status': 1})
- else:
- return jsonify({'status': 2}), 405
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement