diff options
author | François Schmidts <francois.schmidts@gmail.com> | 2016-01-28 14:36:26 +0100 |
---|---|---|
committer | François Schmidts <francois.schmidts@gmail.com> | 2016-01-28 15:08:08 +0100 |
commit | 5c8f9fd0376afc034251a73023e43ada4041aa34 (patch) | |
tree | 5c97be7bfb9d40256704e5394f475b1250086fd6 /src/web/views | |
parent | restoring build command (diff) | |
download | newspipe-5c8f9fd0376afc034251a73023e43ada4041aa34.tar.gz newspipe-5c8f9fd0376afc034251a73023e43ada4041aa34.tar.bz2 newspipe-5c8f9fd0376afc034251a73023e43ada4041aa34.zip |
implementing search through articles
Diffstat (limited to 'src/web/views')
-rw-r--r-- | src/web/views/views.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/web/views/views.py b/src/web/views/views.py index b4833233..90836af1 100644 --- a/src/web/views/views.py +++ b/src/web/views/views.py @@ -234,6 +234,7 @@ from flask import jsonify @app.route('/home2') +@login_required def new_home(): return render_template('home2.html') @@ -265,6 +266,18 @@ def get_menu(): def _get_filters(in_dict): filters = {} + query = in_dict.get('query') + if query: + search_title = in_dict.get('search_title') == 'true' + search_content = in_dict.get('search_content') == 'true' + if search_title: + filters['title__ilike'] = "%%%s%%" % query + if search_content: + filters['content__ilike'] = "%%%s%%" % query + if len(filters) == 0: + filters['title__ilike'] = "%%%s%%" % query + if len(filters) > 1: + filters = {"__or__": filters} if in_dict.get('filter') == 'unread': filters['readed'] = False elif in_dict.get('filter') == 'liked': |