diff --git a/openslides/agenda/search_indexes.py b/openslides/agenda/search_indexes.py new file mode 100644 index 000000000..c4af565fb --- /dev/null +++ b/openslides/agenda/search_indexes.py @@ -0,0 +1,12 @@ +import datetime +from haystack.indexes import * +from haystack import site +from openslides.agenda.models import Item + + +class AgendaIndex(RealTimeSearchIndex): + title = CharField(model_attr='title', null=True) + text = CharField(document=True, model_attr='text', null=True) + + +site.register(Item, AgendaIndex) diff --git a/openslides/global_settings.py b/openslides/global_settings.py index 9c2baea72..9b47a2d9a 100644 --- a/openslides/global_settings.py +++ b/openslides/global_settings.py @@ -118,6 +118,9 @@ INSTALLED_APPS = ( 'openslides.participant', 'openslides.mediafile', 'openslides.config', + + # full-text-search + 'haystack', ) TEMPLATE_CONTEXT_PROCESSORS = ( @@ -142,3 +145,9 @@ TEST_DISCOVER_TOP_LEVEL = os.path.dirname(os.path.dirname(__file__)) # Hosts/domain names that are valid for this site; required if DEBUG is False # See https://docs.djangoproject.com/en/1.5/ref/settings/#allowed-hosts ALLOWED_HOSTS = ['*'] + + +# Full-text search +HAYSTACK_SITECONF = 'openslides.search_sites' +HAYSTACK_SEARCH_ENGINE = 'whoosh' +HAYSTACK_WHOOSH_PATH = os.path.join(os.path.dirname(__file__), 'whoosh_index') diff --git a/openslides/search_sites.py b/openslides/search_sites.py new file mode 100644 index 000000000..a3653e8fd --- /dev/null +++ b/openslides/search_sites.py @@ -0,0 +1,4 @@ +import haystack + + +haystack.autodiscover() diff --git a/openslides/templates/search/search.html b/openslides/templates/search/search.html new file mode 100644 index 000000000..566f1c405 --- /dev/null +++ b/openslides/templates/search/search.html @@ -0,0 +1,39 @@ +{% extends 'base.html' %} + +{% block content %} +