From 860443079de7a4da504345684a1cec97b7d6dadf Mon Sep 17 00:00:00 2001 From: Ozzie Isaacs Date: Mon, 5 Jun 2023 14:41:03 +0200 Subject: [PATCH] Fix for (#2802) search request fails with error after browser session closed and currently returns all results --- cps/search.py | 20 +++++++++++++------- cps/web.py | 2 +- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/cps/search.py b/cps/search.py index 096b2928..4eee2206 100644 --- a/cps/search.py +++ b/cps/search.py @@ -375,13 +375,19 @@ def render_prepare_search_form(cc): def render_search_results(term, offset=None, order=None, limit=None): - join = db.books_series_link, db.Books.id == db.books_series_link.c.book, db.Series - entries, result_count, pagination = calibre_db.get_search_results(term, - config, - offset, - order, - limit, - *join) + if term: + join = db.books_series_link, db.Books.id == db.books_series_link.c.book, db.Series + entries, result_count, pagination = calibre_db.get_search_results(term, + config, + offset, + order, + limit, + *join) + else: + entries = list() + order = [None, None] + pagination = result_count = None + return render_title_template('search.html', searchterm=term, pagination=pagination, diff --git a/cps/web.py b/cps/web.py index 789edd3d..51ff32b3 100755 --- a/cps/web.py +++ b/cps/web.py @@ -396,7 +396,7 @@ def render_books_list(data, sort_param, book_id, page): elif data == "archived": return render_archived_books(page, order) elif data == "search": - term = (request.args.get('query') or '') + term = request.args.get('query', None) offset = int(int(config.config_books_per_page) * (page - 1)) return render_search_results(term, offset, order, config.config_books_per_page) elif data == "advsearch":