diff --git a/combo/apps/search/models.py b/combo/apps/search/models.py index bb923a20..41b0d8ba 100644 --- a/combo/apps/search/models.py +++ b/combo/apps/search/models.py @@ -284,6 +284,9 @@ class SearchCell(CellBase): except ValueError: return render_response(service) + if results.get('err'): + return render_response(service) + if service.get('data_key'): results['data'] = results.get(service['data_key']) or [] hit_templates = {} diff --git a/tests/test_search.py b/tests/test_search.py index 3adffe6f..bc4e8a46 100644 --- a/tests/test_search.py +++ b/tests/test_search.py @@ -317,6 +317,13 @@ def test_search_custom_templates(app): assert '
  • A B' in resp.text assert '
    description A
    ' in resp.text + # err != 0 is handled + response = {'err': 1, 'data': 'something'} + mock_json.json.return_value = response + + resp = app.get('/ajax/search/%s/search2/?q=foo' % cell.pk, status=200) + assert 'no result found' in resp.text + def test_search_cell_visibility(settings, app): request = RequestFactory().get('/')