From 48901cecfcd4abcbd6108f4b77d200c8a49678d2 Mon Sep 17 00:00:00 2001 From: Daniel Date: Wed, 11 Mar 2020 13:22:37 +1300 Subject: [PATCH] always return a list when searching in the api It is not a error when no search results are returned, it is to be expected. The api should return a empty list to show that there were no results (status code 200 OK) rather than a 400 (BAD REQUEST). --- openlp/plugins/bibles/remote.py | 4 +--- openlp/plugins/custom/remote.py | 4 +--- openlp/plugins/images/remote.py | 4 +--- openlp/plugins/media/remote.py | 4 +--- openlp/plugins/presentations/remote.py | 4 +--- openlp/plugins/songs/remote.py | 4 +--- 6 files changed, 6 insertions(+), 18 deletions(-) diff --git a/openlp/plugins/bibles/remote.py b/openlp/plugins/bibles/remote.py index 9426c0cf7..41d1c8d19 100644 --- a/openlp/plugins/bibles/remote.py +++ b/openlp/plugins/bibles/remote.py @@ -61,9 +61,7 @@ def add(id): def search_bible(): text = request.args.get('text', '') result = search(text) - if result: - return jsonify(result) - return '', 400 + return jsonify(result) @v2_views.route('/live', methods=['POST']) diff --git a/openlp/plugins/custom/remote.py b/openlp/plugins/custom/remote.py index 23904db17..d49d4dca3 100644 --- a/openlp/plugins/custom/remote.py +++ b/openlp/plugins/custom/remote.py @@ -61,9 +61,7 @@ def add(id): def search_view(): text = request.args.get('text', '') result = search(text) - if result: - return jsonify(result) - return '', 400 + return jsonify(result) @v2_custom.route('/add', methods=['POST']) diff --git a/openlp/plugins/images/remote.py b/openlp/plugins/images/remote.py index ba3e10e42..46065effc 100644 --- a/openlp/plugins/images/remote.py +++ b/openlp/plugins/images/remote.py @@ -61,9 +61,7 @@ def add(id): def search_view(): text = request.args.get('text', '') result = search(text) - if result: - return jsonify(result) - return '', 400 + return jsonify(result) @v2_images.route('/add', methods=['POST']) diff --git a/openlp/plugins/media/remote.py b/openlp/plugins/media/remote.py index f419ef3d0..83f45e722 100644 --- a/openlp/plugins/media/remote.py +++ b/openlp/plugins/media/remote.py @@ -61,9 +61,7 @@ def add(id): def search_view(): text = request.args.get('text', '') result = search(text) - if result: - return jsonify(result) - return '', 400 + return jsonify(result) @v2_media.route('/add', methods=['POST']) diff --git a/openlp/plugins/presentations/remote.py b/openlp/plugins/presentations/remote.py index 0a97a10d4..1e67b0ad9 100644 --- a/openlp/plugins/presentations/remote.py +++ b/openlp/plugins/presentations/remote.py @@ -61,9 +61,7 @@ def add(id): def search_view(): text = request.args.get('text', '') result = search(text) - if result: - return jsonify(result) - return '', 400 + return jsonify(result) @v2_presentations.route('/add', methods=['POST']) diff --git a/openlp/plugins/songs/remote.py b/openlp/plugins/songs/remote.py index c7bd83e20..98ce1dd82 100644 --- a/openlp/plugins/songs/remote.py +++ b/openlp/plugins/songs/remote.py @@ -61,9 +61,7 @@ def add(id): def search_view(): text = request.args.get('text', '') result = search(text) - if result: - return jsonify(result) - return '', 400 + return jsonify(result) @v2_songs.route('/add', methods=['POST'])