From d836c6e09d0cd205c34bfb6d7d0a86826d6281b2 Mon Sep 17 00:00:00 2001 From: Wqrld Date: Fri, 11 Jul 2025 14:07:16 +0200 Subject: [PATCH] Replace deprecated is_ajax call. This fixes the broken /project/rating endpoint Change-Id: I6d7b7e4defa06b1927d8d31ec828fdaabca2cf39 Signed-off-by: Wqrld --- cloudkittydashboard/dashboards/project/rating/views.py | 2 +- cloudkittydashboard/tests/test_predictive_pricing.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cloudkittydashboard/dashboards/project/rating/views.py b/cloudkittydashboard/dashboards/project/rating/views.py index 87ee80c..f1e9139 100644 --- a/cloudkittydashboard/dashboards/project/rating/views.py +++ b/cloudkittydashboard/dashboards/project/rating/views.py @@ -52,7 +52,7 @@ class IndexView(tables.DataTableView): def quote(request): pricing = 0.0 - if request.is_ajax(): + if request.headers.get('x-requested-with') == 'XMLHttpRequest': if request.method == 'POST': json_data = json.loads(request.body) diff --git a/cloudkittydashboard/tests/test_predictive_pricing.py b/cloudkittydashboard/tests/test_predictive_pricing.py index 38c898b..8fad16b 100644 --- a/cloudkittydashboard/tests/test_predictive_pricing.py +++ b/cloudkittydashboard/tests/test_predictive_pricing.py @@ -36,7 +36,7 @@ class PredictivePricingTest(base.TestCase): def _test_quote_request_not_ajax_post(self, arg): request = mock.MagicMock() if arg == 'ajax': - request.is_ajax.return_value = False + request.headers.get.return_value = None # Not an AJAX request elif arg == 'method': request.method == 'POST' resp = self.quote(request) @@ -57,7 +57,7 @@ class PredictivePricingTest(base.TestCase): {'other_key': None, 'service': 'test_service'}] request = mock.MagicMock() - request.is_ajax.return_value = True + request.headers.get.return_value = 'XMLHttpRequest' request.method = 'POST' request.body = json.dumps(body)