From: Marcin Koziej Date: Mon, 27 Aug 2012 14:27:12 +0000 (+0200) Subject: entry searching works X-Git-Url: https://git.mdrn.pl/prawokultury.git/commitdiff_plain/999340c55d5402900dd013ab5ced2413cd4f22f8?hp=b1fb752ca1abb051a63da4729e34a80affc25c76 entry searching works --- diff --git a/doc/schema.xml b/doc/schema.xml deleted file mode 100644 index 236b417..0000000 --- a/doc/schema.xml +++ /dev/null @@ -1,160 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - id - - - - - - - - diff --git a/migdal/helpers.py b/migdal/helpers.py index 39f5a60..1fdbdd4 100644 --- a/migdal/helpers.py +++ b/migdal/helpers.py @@ -34,9 +34,8 @@ def add_translatable(model, fields, languages=None): for name, field in fields.items(): for lang_code, lang_name in languages: new_field = copy(field) - if hasattr(field, 'verbose_name') and field.verbose_name: + if field.verbose_name: new_field.verbose_name = string_concat(field.verbose_name, ' [%s]' % lang_code) - new_field.contribute_to_class(model, "%s_%s" % (name, lang_code)) setattr(model, name, field_getter(name)) # add setter? diff --git a/migdal/search_indexes.py b/migdal/search_indexes.py index 6223b6e..333899f 100644 --- a/migdal/search_indexes.py +++ b/migdal/search_indexes.py @@ -1,13 +1,14 @@ +from django.conf import settings import datetime from haystack import indexes from migdal.models import Entry -from django.conf import settings + from copy import copy class EntryIndex(indexes.SearchIndex, indexes.Indexable): - date = indexes.DateTimeField(indexed=True) - author = indexes.CharField() + date = indexes.DateTimeField(indexed=True, model_attr="date") + author = indexes.CharField(model_attr="author") def get_model(self): return Entry @@ -26,6 +27,7 @@ def add_translatable(index_class, fields, languages=None): new_field = copy(field) fname = "%s_%s" % (name, lang_code) new_field.index_fieldname = fname + new_field.model_attr = fname setattr(index_class, fname, new_field) index_class.fields[fname] = new_field diff --git a/migdal/templates/search/search.html b/migdal/templates/search/search.html index f38a4e6..6d7b9c7 100644 --- a/migdal/templates/search/search.html +++ b/migdal/templates/search/search.html @@ -8,7 +8,7 @@

{% trans "Search results" %}

{% for result in page.object_list %} -{% entry_short result %} +{% entry_short result.object %} {% empty %}

{% trans "No results found." %}

{% endfor %}