From a3c2bd47e6d9a64539000d4921ee58eed1ea3968 Mon Sep 17 00:00:00 2001 From: François Schmidts Date: Thu, 16 Apr 2015 08:58:11 +0200 Subject: introducing the or filter component --- pyaggr3g470r/views/views.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'pyaggr3g470r/views') diff --git a/pyaggr3g470r/views/views.py b/pyaggr3g470r/views/views.py index 83012d7c..c681a94d 100644 --- a/pyaggr3g470r/views/views.py +++ b/pyaggr3g470r/views/views.py @@ -255,9 +255,8 @@ def render_home(filters={}, head_title='', page_to_render='home', **kwargs): filters['readed'] = filter_ == 'read' if feed_id: filters['feed_id'] = feed_id - if head_title: - head_title += ' - ' - head_title += feed_contr.get(id=feed_id).title + head_title = "%s%s" % (feed_contr.get(id=feed_id).title, + (' - %s' % head_title) if head_title else '') articles = arti_contr.read(**filters).order_by(Article.date.desc()) if limit != 'all': @@ -275,7 +274,7 @@ def render_home(filters={}, head_title='', page_to_render='home', **kwargs): articles = list(articles) if (page_to_render == 'home' and feed_id or page_to_render == 'search') \ - and not articles: + and filter_ != 'all' and not articles: return redirect(gen_url(filter_='all')) if sort_ == "feed": @@ -315,6 +314,8 @@ def search(): filters['title__like'] = "%%%s%%" % query if search_content == 'on': filters['content__like'] = "%%%s%%" % query + if len(filters) > 1: + filters = {"__or__": filters} return render_home(filters, "%s %s" % (gettext('Search:'), query), 'search', search_query=query, search_title=search_title, search_content=search_content) -- cgit