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)
- if not comment_filtered:
- return jsonify({'msg': 'comment not found', 'status': 1})
- has_permission = g.user.is_superuser or g.user.id == Comment.id
- if has_permission:
- comment_filtered.delete()
- db.session.commit()
- return jsonify({'status': 0})
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement