diff --git a/combo/apps/search/models.py b/combo/apps/search/models.py
index fc4aecf2..c06147ff 100644
--- a/combo/apps/search/models.py
+++ b/combo/apps/search/models.py
@@ -14,6 +14,8 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
+import os
+
from django.conf import settings
from django.utils.translation import ugettext_lazy as _
from django import template
@@ -24,6 +26,7 @@ from django.utils.http import quote
from django.template import Context, Template
from jsonfield import JSONField
+from haystack import connections
from combo.utils import requests
from combo.data.models import CellBase
@@ -36,6 +39,7 @@ from . import engines
@register_cell_class
class SearchCell(CellBase):
template_name = 'combo/search-cell.html'
+ manager_form_template = 'combo/manager/search-cell-form.html'
_search_services = JSONField(_('Search Services'), default=dict, blank=True)
@@ -166,3 +170,9 @@ class SearchCell(CellBase):
for k, v in hit_templates.items():
hit[k] = v.render(Context(hit))
return render_response(service, results)
+
+ def has_text_search_service(self):
+ return '_text' in self._search_services.get('data', [])
+
+ def missing_index(self):
+ return not os.path.exists(connections['default'].get_backend().path)
diff --git a/combo/apps/search/templates/combo/manager/search-cell-form.html b/combo/apps/search/templates/combo/manager/search-cell-form.html
new file mode 100644
index 00000000..8e71fb39
--- /dev/null
+++ b/combo/apps/search/templates/combo/manager/search-cell-form.html
@@ -0,0 +1,16 @@
+{% extends "combo/cell_form.html" %}
+{% load i18n %}
+
+{% block cell-form %}
+{% if cell.has_text_search_service and cell.missing_index %}
+
+
+ {% blocktrans %}
+ Content indexing has been scheduled and should happen within an hour; search
+ results will then be available.
+ {% endblocktrans %}
+
+
+{% endif %}
+{{ block.super }}
+{% endblock %}
diff --git a/tests/test_search.py b/tests/test_search.py
index 005755cc..987cb393 100644
--- a/tests/test_search.py
+++ b/tests/test_search.py
@@ -2,6 +2,7 @@ import json
import os
import pytest
import re
+import shutil
import mock
from django.conf import settings
@@ -376,6 +377,41 @@ def test_manager_search_cell(app, admin_user):
assert resp.form['c%s-_search_services' % cells[0].get_reference()].value == ['_text']
+def test_manager_waiting_index_message(app, admin_user):
+ from haystack import connections
+ shutil.rmtree(connections['default'].get_backend().path)
+
+ Page.objects.all().delete()
+ page = Page(title='One', slug='one', template_name='standard')
+ page.save()
+ app = login(app)
+ resp = app.get('/manage/pages/%s/' % page.id)
+ resp = app.get(resp.html.find('option',
+ **{'data-add-url': re.compile('search_searchcell')})['data-add-url'])
+ resp = resp.follow()
+ assert 'Content indexing has been scheduled' not in resp.text
+
+ cells = Page.objects.get(id=page.id).get_cells()
+ resp.form['c%s-_search_services' % cells[0].get_reference()] = ['_text']
+ resp = resp.form.submit().follow()
+ assert 'Content indexing has been scheduled' in resp.text
+
+ call_command('update_index')
+ resp = app.get('/manage/pages/%s/' % page.id)
+ assert 'Content indexing has been scheduled' not in resp.text
+
+
+def test_manager_search_cell(app, admin_user):
+ Page.objects.all().delete()
+ page = Page(title='One', slug='one', template_name='standard')
+ page.save()
+ app = login(app)
+ resp = app.get('/manage/pages/%s/' % page.id)
+ resp = app.get(resp.html.find('option',
+ **{'data-add-url': re.compile('search_searchcell')})['data-add-url'])
+
+
+
def test_wcs_search_engines(app):
with override_settings(KNOWN_SERVICES={}):
search_engines = engines.get_engines()