8 files changed, 1 insertions(+), 172 deletions(-)
M docs/release_notes.rst
D src/wiki/plugins/haystack/README.md
D src/wiki/plugins/haystack/__init__.py
D src/wiki/plugins/haystack/search_indexes.py
D src/wiki/plugins/haystack/templates/search/indexes/wiki/article_text.txt
D src/wiki/plugins/haystack/templates/wiki/plugins/haystack/search.html
D src/wiki/plugins/haystack/views.py
D testproject/testproject/settings/haystack.py
M docs/release_notes.rst => docs/release_notes.rst +1 -1
@@ 37,7 37,7 @@ Removed
~~~~~~~
* Python 3.4 support more or less definitively removed (no longer supported by test suite PyTest)
-
+* Removed unmaintained plugin ``wiki.plugins.haystack``
0.5
---
D src/wiki/plugins/haystack/README.md => src/wiki/plugins/haystack/README.md +0 -13
@@ 1,13 0,0 @@
-Haystack plugin
-===============
-
-***July 16 2013***
-Tested backend, xapian with Haystack 2.0. NB! Get the xapian from Git
-
-https://github.com/notanumber/xapian-haystack
-
-Not working
------------
-
-Do not use Whoosh, it has broken SearchQuerySet support and therefore will leak
-articles that are set non-public.
D src/wiki/plugins/haystack/__init__.py => src/wiki/plugins/haystack/__init__.py +0 -61
@@ 1,61 0,0 @@
-from django.db.models import Q
-from django.shortcuts import redirect
-from django.utils.decorators import classonlymethod
-from haystack import views as haystack_views
-from wiki import models
-from wiki.conf import settings
-from wiki.core import permissions
-
-
-class SearchViewHaystack(haystack_views.SearchView):
- results_per_page = 25
- template = "search/search.html"
-
- def __name__(self): # @ReservedAssignment
- return "SearchViewHaystack"
-
- @classonlymethod
- def as_view(cls, *args, **kwargs):
- return haystack_views.search_view_factory(view_class=cls, *args, **kwargs)
-
- def dispatch(self, request, *args, **kwargs):
- # Do not allow anonymous users to search if they cannot read content
- if request.user.is_anonymous and not settings.ANONYMOUS:
- return redirect(settings.LOGIN_URL)
- return super().dispatch(request, *args, **kwargs)
-
- def __filter_can_read(self, user):
- """Filter objects so only the ones with a user's reading access
- are included"""
- if user.has_perm('wiki.moderator'):
- return self.results
- if user.is_anonymous:
- q = self.results.filter(other_read='True')
- return q
- else:
- q = self.results.filter(
- Q(other_read=True) |
- Q(owner=user) |
- (Q(group__user=user) & Q(group_read=True))
- )
- return q
-
- def __call__(self, request):
- self.request = request
- if self.request.user.is_anonymous and not settings.ANONYMOUS:
- return redirect(settings.LOGIN_URL)
-
- self.form = self.build_form()
- self.query = self.get_query()
- self.results = self.get_results()
- if not permissions.can_moderate(
- models.URLPath.root().article,
- self.request.user):
- self.results = self.__filter_can_read(self.request.user)
-
- return self.create_response()
-
- def extra_context(self):
- extra = super().extra_context()
- extra['search_query'] = self.query
- return extra
D src/wiki/plugins/haystack/search_indexes.py => src/wiki/plugins/haystack/search_indexes.py +0 -24
@@ 1,24 0,0 @@
-from haystack import indexes
-from wiki import models
-
-
-class ArticleIndex(indexes.SearchIndex, indexes.Indexable):
- text = indexes.CharField(document=True, use_template=True)
- created = indexes.DateTimeField(model_attr='created')
- modified = indexes.DateTimeField(model_attr='modified')
-
- # default because indexing fails with whoosh. see.
- # http://stackoverflow.com/questions/11995367/how-do-i-use-a-boolean-field-in-django-haystack-search-query
- # https://github.com/toastdriven/django-haystack/issues/382
- other_read = indexes.BooleanField(model_attr='other_read', default=False)
- group_read = indexes.BooleanField(model_attr='group_read', default=False)
-
- owner_id = indexes.IntegerField(model_attr='owner__id', null=True)
- group_id = indexes.IntegerField(model_attr='group__id', null=True)
-
- def get_model(self):
- return models.Article
-
- def index_queryset(self, using=None):
- """Used when the entire index for model is updated."""
- return self.get_model().objects.all()
D src/wiki/plugins/haystack/templates/search/indexes/wiki/article_text.txt => src/wiki/plugins/haystack/templates/search/indexes/wiki/article_text.txt +0 -2
@@ 1,2 0,0 @@
-{{ object.current_revision.title }}
-{{ object.render|striptags }}
D src/wiki/plugins/haystack/templates/wiki/plugins/haystack/search.html => src/wiki/plugins/haystack/templates/wiki/plugins/haystack/search.html +0 -7
@@ 1,7 0,0 @@
-{% extends "wiki/search.html" %}
-
-{% block wiki_search_loop %}
-{% with article.object as article %}
-{% include "wiki/includes/searchresult.html" %}
-{% endwith %}
-{% endblock %}
D src/wiki/plugins/haystack/views.py => src/wiki/plugins/haystack/views.py +0 -32
@@ 1,32 0,0 @@
-from haystack.backends import SQ
-from haystack.inputs import AutoQuery
-from haystack.query import SearchQuerySet
-from wiki import models
-from wiki.core import permissions
-from wiki.views.article import SearchView
-
-
-class HaystackSearchView(SearchView):
-
- template_name = 'wiki/plugins/haystack/search.html'
-
- def get_queryset(self):
- qs = SearchQuerySet().all()
- if self.request.user.is_authenticated:
- if not permissions.can_moderate(
- models.URLPath.root().article,
- self.request.user):
- qs = qs.filter(
- SQ(owner_id=self.request.user.id) |
- (
- SQ(group_id__in=self.request.user.groups.values_list('id', flat=True)) &
- SQ(group_read=True)
- ) |
- SQ(other_read=True)
- )
- else:
- qs = qs.exclude(other_read=False)
-
- qs = qs.filter(content=AutoQuery(self.query))
- qs = qs.load_all()
- return qs
D testproject/testproject/settings/haystack.py => testproject/testproject/settings/haystack.py +0 -32
@@ 1,32 0,0 @@
-from .base import * # noqa @UnusedWildImport
-
-# Django Haystack
-
-HAYSTACK_WHOOSH_PATH = os.path.join(PROJECT_DIR, 'index_woosh')
-
-INSTALLED_APPS += ['haystack', 'wiki.plugins.haystack']
-
-HAYSTACK_CONNECTIONS = {
- 'default': {
- 'ENGINE': 'haystack.backends.simple_backend.SimpleEngine',
- },
-}
-
-
-HAYSTACK_CONNECTIONS = {
- 'default': {
- 'ENGINE': 'xapian_backend.XapianEngine',
- 'PATH': os.path.join(PROJECT_DIR, 'xapian_index'),
- },
-}
-
-# Whoosh backend is completely broken
-# https://github.com/toastdriven/django-haystack/issues/522
-# https://github.com/toastdriven/django-haystack/issues/382
-# https://github.com/toastdriven/django-haystack/issues/447
-# HAYSTACK_CONNECTIONS = {
-# 'default': {
-# 'ENGINE': 'haystack.backends.whoosh_backend.WhooshEngine',
-# 'PATH': os.path.join(PROJECT_PATH, 'whoosh_index'),
-# },
-# }