msgstr ""
"Project-Id-Version: django-migdal 0.1\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2012-08-28 12:10+0200\n"
-"PO-Revision-Date: 2012-08-28 12:14+0100\n"
-"Last-Translator: Radek Czajka <radoslaw.czajka@nowoczesnapolska.org.pl>\n"
+"POT-Creation-Date: 2012-08-28 12:37+0200\n"
+"PO-Revision-Date: 2012-08-28 12:38+0100\n"
+"Last-Translator: Marcin Koziej <marcin@lolownia.org>\n"
"Language-Team: FNP <fundacja@nowoczesnapolska.org.pl>\n"
"Language: Polish\n"
"MIME-Version: 1.0\n"
msgstr "kategoria"
#: models.py:19
-#: urls.py:40
-#: urls.py:42
+#: urls.py:41
+#: urls.py:43
msgid "categories"
msgstr "kategorie"
msgid "file"
msgstr "plik"
-#: urls.py:37
#: urls.py:38
+#: urls.py:39
msgid "submit"
msgstr "wyslij"
-#: urls.py:38
+#: urls.py:39
msgid "thanks"
msgstr "dzieki"
+#: urls.py:45
+msgid "search"
+msgstr "szukaj"
+
#: templates/comments/migdal/entry/preview.html:19
msgid "Please correct the error below"
msgid_plural "Please correct the errors below"
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import string_concat
from migdal import feeds, app_settings
+from migdal.views import SearchPublishedView
from migdal.helpers import i18n_patterns
pats = []
'migdal.views.entry_list', name='migdal_category'),
url(string_concat(r'^', _('categories'), r'/(?P<category_slug>[^/]*)/rss.xml$'),
feeds.EntriesFeed(), name='migdal_category_feed'),
+ url(string_concat(r'^', _('search')), SearchPublishedView(), name='search'),
# type-specific views
*pats
)
# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
#
from django.shortcuts import get_object_or_404, render, redirect
+from django.utils.translation import get_language
from migdal import api
from migdal.forms import get_submit_form
from migdal.models import Category, Entry
from migdal import app_settings
+from haystack.views import SearchView
def entry_list(request, type_db=None, category_slug=None):
})
def submit_thanks(request):
- return render(request, "migdal/entry/submit_thanks.html")
\ No newline at end of file
+ return render(request, "migdal/entry/submit_thanks.html")
+
+
+class SearchPublishedView(SearchView):
+ def __init__(self, *args, **kwargs):
+ super(SearchPublishedView, self).__init__(*args, **kwargs)
+
+ def get_results(self):
+ results = super(SearchPublishedView, self).get_results()
+ lang_code = get_language()
+ def is_published(entity):
+ print "is published? %s, %s" % (entity.published_pl, entity.published_en)
+ if isinstance(entity, Entry):
+ return getattr(entity, "published_%s" % lang_code) == True
+ else:
+ return True
+ results = filter(lambda r: is_published(r.object), results)
+ print results
+ return results
<div id="menu-bar">
<div class="bar-right">
- <form id="search-form" method="GET" action="/search/"><input name="q" /><button>
+ <form id="search-form" method="GET" action="{% url 'search' %}"><input name="q" /><button>
<img src="{% static "img/search.png" %}" alt="{% trans "Search" %}" />
</button></form>
</div>
url(r'^media/(?P<path>.*)$', 'django.views.static.serve', {
'document_root': settings.MEDIA_ROOT,
}),
- url(r'^search/', include('haystack.urls')),
) + i18n_patterns('',
url(string_concat(r'^', _('events'), r'/'), include('events.urls')),
url(r'^comments/', include('django_comments_xtd.urls')),