Permalink
Browse files

Merge branch 'release/0.5'

  • Loading branch information...
2 parents dcd8d20 + 3b23e30 commit 2be0b846db14630458ad36118257eea147fbb61c @beniwohli committed Mar 28, 2012
Showing with 40 additions and 16 deletions.
  1. +11 −1 README.rst
  2. +1 −1 cms_search/__init__.py
  3. +0 −2 cms_search/cms_app.py
  4. +14 −7 cms_search/search_indexes.py
  5. +3 −3 docs/conf.py
  6. +10 −1 docs/index.rst
  7. +1 −1 metadata.py
View
@@ -13,4 +13,14 @@ After installing django-cms-search through your package manager of choice, add `
For setting up Haystack, please refer to their `documentation <http://docs.haystacksearch.org/dev/>`_.
For more docs, see the ``docs`` folder or the
-`online documentation <http://django-cms-search.readthedocs.org/en/latest/>`_.
+`online documentation <http://django-cms-search.readthedocs.org/en/latest/>`_.
+
+
+.. warning::
+
+ Since version 0.5, the ``HaystackSearchApphook`` is not registered automatically
+ anymore. If you want do use the default app hook provided by django-cms-search,
+ add this (e.g. in ``models.py``)::
+
+ from cms_search.cms_app import HaystackSearchApphook
+ apphook_pool.register(HaystackSearchApphook)
View
@@ -1 +1 @@
-__version__ = '0.4.1'
+__version__ = '0.5'
View
@@ -2,7 +2,6 @@
from django.utils.translation import ugettext_lazy as _
from cms.app_base import CMSApp
-from cms.apphook_pool import apphook_pool
from haystack.views import search_view_factory
@@ -12,4 +11,3 @@ class HaystackSearchApphook(CMSApp):
url('^$', search_view_factory(), name='haystack-search'),
),]
-apphook_pool.register(HaystackSearchApphook)
@@ -7,7 +7,7 @@
from django.utils.translation import get_language, activate
try:
- from django.test.client import RequestFactoryII
+ from django.test.client import RequestFactory
except ImportError:
from cms_search.utils import RequestFactory
@@ -49,7 +49,8 @@ def _get_index_base():
def page_index_factory(language_code, proxy_model):
class _PageIndex(_get_index_base()):
- language = language_code
+ _language = language_code
+ language = indexes.CharField()
text = indexes.CharField(document=True, use_template=False)
pub_date = indexes.DateTimeField(model_attr='publication_date', null=True)
@@ -61,25 +62,31 @@ class _PageIndex(_get_index_base()):
def prepare(self, obj):
current_languge = get_language()
try:
- activate(self.language)
+ activate(self._language)
request = rf.get("/")
request.session = {}
self.prepared_data = super(_PageIndex, self).prepare(obj)
plugins = CMSPlugin.objects.filter(language=language_code, placeholder__in=obj.placeholders.all())
- text = ''
+ text = u''
for plugin in plugins:
instance, _ = plugin.get_plugin_instance()
if hasattr(instance, 'search_fields'):
- text += u''.join(force_unicode(_strip_tags(getattr(instance, field, ''))) for field in instance.search_fields)
+ text += u' '.join(force_unicode(_strip_tags(getattr(instance, field, ''))) for field in instance.search_fields)
if getattr(instance, 'search_fulltext', False):
- text += _strip_tags(instance.render_plugin(context=RequestContext(request)))
+ text += _strip_tags(instance.render_plugin(context=RequestContext(request))) + u' '
+ text += obj.get_meta_description() or u''
+ text += u' '
+ text += obj.get_meta_keywords() or u''
self.prepared_data['text'] = text
+ self.prepared_data['language'] = self._language
return self.prepared_data
finally:
activate(current_languge)
def index_queryset(self):
- qs = proxy_model.objects.published().filter(title_set__language=language_code).distinct()
+ # get the correct language and exclude pages that have a redirect
+ qs = proxy_model.objects.published().filter(
+ title_set__language=language_code, title_set__redirect__isnull=True).distinct()
if 'publisher' in settings.INSTALLED_APPS:
qs = qs.filter(publisher_is_draft=True)
return qs
View
@@ -39,16 +39,16 @@
# General information about the project.
project = u'django-cms-search'
-copyright = u'2011, Divio GmbH'
+copyright = u'2012, Divio AG'
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
-version = '0.4.1'
+version = '0.5'
# The full version, including alpha/beta/rc tags.
-release = '0.4.1'
+release = '0.5'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
View
@@ -11,6 +11,15 @@ Usage
After installing django-cms-search through your package manager of choice, add
:mod:`cms_search` to your :setting:`INSTALLED_APPS`. That's it.
+.. warning::
+
+ Since version 0.5, the ``HaystackSearchApphook`` is not registered automatically
+ anymore. If you want do use the default app hook provided by django-cms-search,
+ add this (e.g. in ``models.py``)::
+
+ from cms_search.cms_app import HaystackSearchApphook
+ apphook_pool.register(HaystackSearchApphook)
+
For setting up Haystack, please refer to their
`documentation <http://readthedocs.org/docs/django-haystack/en/latest/>`_.
@@ -142,4 +151,4 @@ Default: :class:`haystack.indexes.SearchIndex <haystack:SearchIndex>`
This setting can be used to add custom fields to the search index if the
included fields do not suffice. Make sure to provide the full path
-to your :class:`haystack:SearchIndex` subclass.
+to your :class:`haystack:SearchIndex` subclass.
View
@@ -1,6 +1,6 @@
package_name = 'cms_search'
name = 'django-cms-search'
-author = 'Divio GmbH'
+author = 'Divio AG'
author_email = 'developers@divio.ch'
description = "An extension to django CMS to provide multilingual Haystack indexes"
version = __import__(package_name).__version__

0 comments on commit 2be0b84

Please sign in to comment.