From 05189f78bc862ee6c323bf5513ec9e27899e0693 Mon Sep 17 00:00:00 2001 From: OzzieIsaacs Date: Wed, 5 Oct 2016 12:44:32 +0200 Subject: [PATCH] Fix for #67 --- cps/web.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cps/web.py b/cps/web.py index 6ef8c0cd..7d85cd3c 100755 --- a/cps/web.py +++ b/cps/web.py @@ -474,8 +474,9 @@ def admin(): @app.route("/search", methods=["GET"]) @login_required_if_no_ano def search(): - term = request.args.get("query").strip() + term = request.args.get("query") if term: + term=term.strip() random = db.session.query(db.Books).order_by(func.random()).limit(config.RANDOM_BOOKS) entries = db.session.query(db.Books).filter(db.or_(db.Books.tags.any(db.Tags.name.like("%"+term+"%")),db.Books.series.any(db.Series.name.like("%"+term+"%")),db.Books.authors.any(db.Authors.name.like("%"+term+"%")),db.Books.title.like("%"+term+"%"))).all() return render_template('search.html', searchterm=term, entries=entries)