aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCédric Bonhomme <cedric@cedricbonhomme.org>2015-04-23 09:27:22 +0200
committerCédric Bonhomme <cedric@cedricbonhomme.org>2015-04-23 09:27:22 +0200
commit387b2c02f11ceccb7161866d089b21d1870703b4 (patch)
tree6af1c1177dd6db9e7fcf98a2b8fec5f78a004cda
parentBugfix: 'searc_content' -> 'search_content'. (diff)
downloadnewspipe-387b2c02f11ceccb7161866d089b21d1870703b4.tar.gz
newspipe-387b2c02f11ceccb7161866d089b21d1870703b4.tar.bz2
newspipe-387b2c02f11ceccb7161866d089b21d1870703b4.zip
Fixed strange behaviour of the search when only searching on the content.
-rw-r--r--pyaggr3g470r/views/views.py12
1 files changed, 9 insertions, 3 deletions
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)],
bgstack15