Skip to content

Commit 8b7bdbf

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "Replace deprecated is_ajax call. This fixes the broken /project/rating endpoint"
2 parents 82b64c3 + d836c6e commit 8b7bdbf

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

cloudkittydashboard/dashboards/project/rating/views.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def get_data(self):
5252

5353
def quote(request):
5454
pricing = 0.0
55-
if request.is_ajax():
55+
if request.headers.get('x-requested-with') == 'XMLHttpRequest':
5656
if request.method == 'POST':
5757
json_data = json.loads(request.body)
5858

cloudkittydashboard/tests/test_predictive_pricing.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def setUp(self):
3636
def _test_quote_request_not_ajax_post(self, arg):
3737
request = mock.MagicMock()
3838
if arg == 'ajax':
39-
request.is_ajax.return_value = False
39+
request.headers.get.return_value = None # Not an AJAX request
4040
elif arg == 'method':
4141
request.method == 'POST'
4242
resp = self.quote(request)
@@ -57,7 +57,7 @@ def test_quote_does_update_request_dict(self, api_mock):
5757
{'other_key': None, 'service': 'test_service'}]
5858

5959
request = mock.MagicMock()
60-
request.is_ajax.return_value = True
60+
request.headers.get.return_value = 'XMLHttpRequest'
6161
request.method = 'POST'
6262
request.body = json.dumps(body)
6363

0 commit comments

Comments
 (0)