From 387b2c02f11ceccb7161866d089b21d1870703b4 Mon Sep 17 00:00:00 2001 From: Cédric Bonhomme Date: Thu, 23 Apr 2015 09:27:22 +0200 Subject: Fixed strange behaviour of the search when only searching on the content. --- pyaggr3g470r/views/views.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'pyaggr3g470r/views') diff --git a/pyaggr3g470r/views/views.py b/pyaggr3g470r/views/views.py index 4b5f0164..c1e96bc4 100644 --- a/pyaggr3g470r/views/views.py +++ b/pyaggr3g470r/views/views.py @@ -276,8 +276,11 @@ def render_home(filters=None, head_titles=None, **kwargs): if page_to_render == 'search': kwargs['query'] = request.args.get('query', '') - kwargs['search_title'] = request.args.get('search_title', 'on') + kwargs['search_title'] = request.args.get('search_title', 'off') kwargs['search_content'] = request.args.get('search_content', 'off') + if kwargs['search_title']=='off' and \ + kwargs['search_content']=='off': + kwargs['search_title'] = 'on' return url_for(page_to_render, filter_=filter_, sort_=sort_, limit=limit, feed_id=feed_id, **kwargs) @@ -314,12 +317,15 @@ def search(): return render_home() query = request.args['query'] filters = {} - search_title = request.args.get('search_title') - search_content = request.args.get('search_content') + search_title = request.args.get('search_title', 'off') + search_content = request.args.get('search_content', 'off') if search_title == 'on': filters['title__like'] = "%%%s%%" % query if search_content == 'on': filters['content__like'] = "%%%s%%" % query + if len(filters) == 0: + search_title = 'on' + filters['title__like'] = "%%%s%%" % query if len(filters) > 1: filters = {"__or__": filters} return render_home(filters, ["%s %s" % (gettext('Search:'), query)], -- cgit