Commit 53b0ea31 authored by alexandre.jauneau's avatar alexandre.jauneau

Add whoosh for dev and test

parent f306e5e7
Pipeline #994 failed with stage
in 9 minutes and 7 seconds
......@@ -36,3 +36,4 @@ data/
# local setup
.memopol.alias
whoosh_index/
......@@ -31,7 +31,8 @@ setup(name='political-memory',
'django-suit>=0.2,<0.3',
'psycopg2>=2,<3',
'django-haystack==2.6.0',
'pysolr==3.6.0'
'pysolr==3.6.0',
'Whoosh==2.7.4'
],
extras_require={
# Full version hardcode for testing dependencies so that
......
......@@ -344,11 +344,17 @@ if os.path.exists(RAVEN_FILE):
RAVEN_CONFIG = {'dsn': f.read().strip()}
# Haystack with Solr config
DJANGO_HAYSTACK_ENABLE = True
if DJANGO_HAYSTACK_ENABLE:
if not DEBUG:
HAYSTACK_CONNECTIONS = {
'default': {
'ENGINE': 'haystack.backends.solr_backend.SolrEngine',
'URL': 'http://127.0.0.1:8080/solr',
},
}
else:
HAYSTACK_CONNECTIONS = {
'default': {
'ENGINE': 'haystack.backends.whoosh_backend.WhooshEngine',
'PATH': os.path.join(os.path.dirname(__file__), 'whoosh_index'),
},
}
......@@ -7,7 +7,6 @@ from memopol.utils import strip_accents
def search_autocomplete(request):
if request.is_ajax():
q = strip_accents(request.GET.get('term', ''))
print q
if q is not None:
json_results = []
sqs = SearchQuerySet().autocomplete(ascii_name=q)
......@@ -18,7 +17,6 @@ def search_autocomplete(request):
result_json['value'] = result.full_name
result_json['link'] = reverse('representative-detail', kwargs={'slug': result.slug})
json_results.append(result_json)
print result.ascii_name
data = json.dumps(json_results)
else:
data = "Fail"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment