summaryrefslogtreecommitdiff
path: root/chimere/views.py
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@proxience.com>2015-02-22 14:31:39 +0100
committerÉtienne Loks <etienne.loks@proxience.com>2015-02-22 14:31:39 +0100
commitc3571474b92e3eb716d2646fa66357e4c61f2d81 (patch)
treece77d7630fbcc8adeb75a39b35847ce818621426 /chimere/views.py
parentfeeef0681606a2e9ab417970ae279ffd882b84ab (diff)
downloadChimère-c3571474b92e3eb716d2646fa66357e4c61f2d81.tar.bz2
Chimère-c3571474b92e3eb716d2646fa66357e4c61f2d81.zip
Search: work on spelling suggestion
Diffstat (limited to 'chimere/views.py')
-rw-r--r--chimere/views.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/chimere/views.py b/chimere/views.py
index a696d5a..8daa432 100644
--- a/chimere/views.py
+++ b/chimere/views.py
@@ -962,9 +962,15 @@ if hasattr(settings, 'CHIMERE_SEARCH_ENGINE') \
sqs = SearchQuerySet().autocomplete(
content_auto=request.GET.get('q', ''))[:5]
suggestions = [result.object.name for result in sqs if result.object]
+ spelling = []
+ if not suggestions:
+ spelling = SearchQuerySet().spelling_suggestion(
+ request.GET.get('q', '')) or []
+ # convert to list spelling...
# make sure it returns a JSON object, not a bare list.
# otherwise, it could be vulnerable to an XSS attack.
the_data = json.dumps({
- 'results': suggestions
+ 'results': suggestions,
+ 'spelling':spelling,
})
return HttpResponse(the_data, content_type='application/json')