1 # -*- coding: utf-8 -*-
2 # This file is part of PrawoKultury, licensed under GNU Affero GPLv3 or later.
3 # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
5 from django.conf import settings
6 from haystack import indexes
7 from fnpdjango.utils.models.translation import add_translatable_index, localize_field
8 from migdal.models import Entry
11 class EntryIndex(indexes.SearchIndex, indexes.Indexable):
12 text = indexes.CharField(
14 model_attr=localize_field('body', settings.LANGUAGE_CODE),
16 date = indexes.DateTimeField(indexed=True, model_attr="date")
17 author = indexes.CharField(model_attr="author")
23 add_translatable_index(EntryIndex, {
24 'title': indexes.CharField(null=True),
25 'lead': indexes.CharField(null=True),
28 add_translatable_index(EntryIndex, {
29 'title': indexes.CharField(null=True),
30 'lead': indexes.CharField(null=True),
31 'body': indexes.CharField(null=True)
33 (lang for lang in settings.LANGUAGES if lang[0] != settings.LANGUAGE_CODE)