diff options
author | Aurélien Bompard <aurelien@bompard.org> | 2013-10-22 15:00:23 +0200 |
---|---|---|
committer | Aurélien Bompard <aurelien@bompard.org> | 2013-10-22 15:00:23 +0200 |
commit | 85423f0b064aaa4f712acaecc66df1ecda360081 (patch) | |
tree | e5c48a28f87a891b39978588597b24eb2fd6a1df | |
parent | f1a0a71d971ffa4c01a88b92aa4869dd3a12a3fa (diff) | |
download | hyperkitty-85423f0b064aaa4f712acaecc66df1ecda360081.tar.gz hyperkitty-85423f0b064aaa4f712acaecc66df1ecda360081.tar.xz hyperkitty-85423f0b064aaa4f712acaecc66df1ecda360081.zip |
Deal with a disabled search engine
-rw-r--r-- | hyperkitty/templates/error-nosearch.html | 31 | ||||
-rw-r--r-- | hyperkitty/views/search.py | 3 | ||||
-rw-r--r-- | hyperkitty/views/thread.py | 7 |
3 files changed, 39 insertions, 2 deletions
diff --git a/hyperkitty/templates/error-nosearch.html b/hyperkitty/templates/error-nosearch.html new file mode 100644 index 0000000..e27e153 --- /dev/null +++ b/hyperkitty/templates/error-nosearch.html @@ -0,0 +1,31 @@ +{% extends "base.html" %} +{% load url from future %} +{% load gravatar %} +{% load hk_generic %} +{% load storm %} + + +{% block title %} +Error: no search engine available +{% if mlist %} + - {{ mlist.display_name|default:mlist.name|escapeemail }} +{% endif %} + - {{ app_name|title }} +{% endblock %} + +{% block content %} + +<div class="row-fluid"> + + <div class="span2"> + </div> + + <div class="span7"> + <p class="text-error"> + Sorry, the search engine is not available (it has been disabled for this site). + </p> + </div> + +</div> + +{% endblock %} diff --git a/hyperkitty/views/search.py b/hyperkitty/views/search.py index 3eb179f..55fc95a 100644 --- a/hyperkitty/views/search.py +++ b/hyperkitty/views/search.py @@ -91,6 +91,9 @@ def search(request, page=1): "mlist": mlist, }, status=403) + if not store.search_index: + return render(request, "error-nosearch.html", {"mlist": mlist}) + if not query: return render(request, "search_results.html", { 'mlist' : mlist, diff --git a/hyperkitty/views/thread.py b/hyperkitty/views/thread.py index 6f70b86..f0d2fb6 100644 --- a/hyperkitty/views/thread.py +++ b/hyperkitty/views/thread.py @@ -405,8 +405,11 @@ def reattach_suggest(request, mlist_fqdn, threadid): if not search_query: search_query = default_search_query search_query = search_query.strip() - search_result = store.search(search_query, mlist_fqdn, 1, 50) - messages = search_result["results"] + if store.search_index: + search_result = store.search(search_query, mlist_fqdn, 1, 50) + messages = search_result["results"] + else: + messages = [] suggested_threads = [] for msg in messages: if msg.thread not in suggested_threads and msg.thread_id != threadid: |