diff --git a/welco/kb/templates/kb/page_search.html b/welco/kb/templates/kb/page_search.html
new file mode 100644
index 0000000..aa7d629
--- /dev/null
+++ b/welco/kb/templates/kb/page_search.html
@@ -0,0 +1,25 @@
+{% extends "kb/base.html" %}
+{% load i18n %}
+
+{% block appbar %}
+
{% trans 'Knowledge Base' %}
+{% endblock %}
+
+{% block content %}
+
+
+{% if object_list %}
+
+ {% for page in object_list %}
+
+ {% endfor %}
+
+{% endif %}
+
+
+{% endblock %}
diff --git a/welco/kb/views.py b/welco/kb/views.py
index 2ba9eab..7946a2c 100644
--- a/welco/kb/views.py
+++ b/welco/kb/views.py
@@ -18,12 +18,20 @@ from django.core.urlresolvers import reverse_lazy
from django.views.generic import (DetailView, CreateView, UpdateView,
ListView, DeleteView)
+from haystack.forms import SearchForm
+from haystack.generic_views import SearchView
+
from .models import Page
class PageListView(ListView):
model = Page
+ def get_context_data(self, **kwargs):
+ context = super(PageListView, self).get_context_data(**kwargs)
+ context['form'] = SearchForm()
+ return context
+
page_list = PageListView.as_view()
@@ -50,3 +58,10 @@ class PageDeleteView(DeleteView):
success_url = reverse_lazy('kb-home')
page_delete = PageDeleteView.as_view()
+
+
+class PageSearchView(SearchView):
+ template_name = 'kb/page_search.html'
+ form_class = SearchForm
+
+page_search = PageSearchView.as_view()
diff --git a/welco/settings.py b/welco/settings.py
index 57e70ed..a5ae869 100644
--- a/welco/settings.py
+++ b/welco/settings.py
@@ -40,6 +40,7 @@ INSTALLED_APPS = (
'django.contrib.staticfiles',
'django_select2',
'ckeditor',
+ 'haystack',
'welco.sources.mail',
'welco.qualif',
'welco.kb',
@@ -148,6 +149,16 @@ MELLON_USERNAME_TEMPLATE = '{attributes[name_id_content]}'
MELLON_IDENTITY_PROVIDERS = []
+
+# indexing
+HAYSTACK_CONNECTIONS = {
+ 'default': {
+ 'ENGINE': 'haystack.backends.whoosh_backend.WhooshEngine',
+ 'PATH': os.path.join(BASE_DIR, 'whoosh_index'),
+ },
+}
+
+
local_settings_file = os.environ.get('WELCO_SETTINGS_FILE',
os.path.join(os.path.dirname(__file__), 'local_settings.py'))
if os.path.exists(local_settings_file):
diff --git a/welco/static/css/style.css b/welco/static/css/style.css
index 6aed542..683254a 100644
--- a/welco/static/css/style.css
+++ b/welco/static/css/style.css
@@ -140,4 +140,6 @@ div.objects-list > div.level-1 {
margin-left: 25px;
}
-
+form#kb-search {
+ margin-bottom: 2em;
+}
diff --git a/welco/urls.py b/welco/urls.py
index 9812ea1..cb52d0f 100644
--- a/welco/urls.py
+++ b/welco/urls.py
@@ -26,6 +26,7 @@ urlpatterns = patterns('',
url(r'^kb/$', 'welco.kb.views.page_list', name='kb-home'),
url(r'^kb/add/$', 'welco.kb.views.page_add', name='kb-page-add'),
+ url(r'^kb/search/$', 'welco.kb.views.page_search', name='kb-page-search'),
url(r'^kb/(?P
[\w-]+)/$', 'welco.kb.views.page_detail', name='kb-page-view'),
url(r'^kb/(?P[\w-]+)/edit$', 'welco.kb.views.page_edit', name='kb-page-edit'),
url(r'^kb/(?P[\w-]+)/delete$', 'welco.kb.views.page_delete', name='kb-page-delete'),