Commit 815d9b48 authored by Robert's avatar Robert

Replaced watson by haystack with xapian

parent e8445596
Pipeline #1149 failed with stage
in 2 minutes and 22 seconds
......@@ -6,7 +6,7 @@ db.sqlite3*
media/
node_modules
static/
whoosh_index
xapian_index
res/img/backdrops
stadt/settings/local.py
*.swp
......
from django.apps import AppConfig
from watson import search as watson
class AssociationsConfig(AppConfig):
name = "features.associations"
def ready(self):
watson.register(
self.get_model("Association").objects.exclude_deleted().filter(public=True),
fields=(
'content__title',
'content__place',
'content__versions__text',
#'content__taggeds__tag__name',
'content__contributions__contribution__text',
))
pass
from haystack import indexes
from haystack.indexes import Indexable, SearchIndex
from .models import Association
class AssociationIndex(Indexable, SearchIndex):
text = indexes.CharField(document=True, use_template=True)
def get_model(self):
return Association
def index_queryset(self, using=None):
return self.get_model().objects.exclude_deleted().filter(public=True)
from django.conf.urls import url
from django.conf.urls import include, url
from . import feeds, views
......
......@@ -3,8 +3,9 @@ from django.conf import settings
from django.contrib.sites.shortcuts import get_current_site
from django.shortcuts import get_object_or_404
from django.views.generic import ListView
from watson.views import SearchMixin
from django.urls import reverse
from haystack.inputs import AutoQuery
from haystack.query import SearchQuerySet
import core
from core.views import PermissionMixin
......@@ -66,7 +67,10 @@ class Privacy(core.views.PageMixin, django.views.generic.TemplateView):
return super().get_context_data(**kwargs)
class Search(PermissionMixin, SearchMixin, ListView):
class Search(PermissionMixin, ListView):
permission_required = 'stadt.search'
paginate_by = 10
template_name = 'stadt/search.html'
def get_queryset(self):
return SearchQuerySet().filter(text=AutoQuery(self.request.GET['q']))
bleach # debian: python3-bleach
django # debian: python3-django
django<2 # debian: python3-django
django-allauth # debian (buster): python3-django-allauth
django-crispy-forms # debian: python3-django-crispy-forms
django-filter # debian: python3-django-filters
......@@ -20,3 +20,4 @@ raven # NOT IN DEBIAN
requests # debian: python3-requests
rules # debian (buster): python3-django-rules
translitcodec # NOT IN DEBIAN
xapian-haystack # NOT IN DEBIAN
......@@ -308,7 +308,13 @@ TAGS_TAGGABLE = (
)
# Search (engine)
# https://github.com/etianen/django-watson/wiki/language-support
# Search engine
# https://django-haystack.readthedocs.io/
WATSON_POSTGRES_SEARCH_CONFIG = "pg_catalog.german"
HAYSTACK_CONNECTIONS = {
'default': {
'ENGINE': 'xapian_backend.XapianEngine',
'PATH': os.path.join(
os.path.dirname(os.path.dirname(os.path.dirname(__file__))), 'xapian_index'),
},
}
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