diff --git a/cps/editbooks.py b/cps/editbooks.py index 2fe40f3c..ca25b95e 100644 --- a/cps/editbooks.py +++ b/cps/editbooks.py @@ -215,7 +215,11 @@ def table_get_custom_enum(c_id): @edit_required def edit_list_book(param): vals = request.get_json() - return jsonify(edit_book_param(param, vals)) + ret_value = edit_book_param(param, vals) + if isinstance(ret_value, dict): + return jsonify(ret_value) + else: + return ret_value @editbook.route("/ajax/editselectedbooks", methods=['POST']) @login_required_if_no_ano @@ -233,6 +237,9 @@ def edit_selected_books(): publishers = d.get('publishers') comments = d.get('comments') + if not ( + title or title_sort or authors or categories or series or languages or publishers or comments) or not selections: + return _("Parameter not found"), 400 vals = { "pk": selections, "value": None, @@ -307,7 +314,7 @@ def edit_book_param(param, vals, multi=False): elements = vals.get('pk',[]) if vals.get('value', None) is None: return {'success':False, 'msg':_("Value is missing on request")} - if not elements : + if not elements or len(elements) > 1 and multi == False: return {"success":False, "msg":_("Oops! Selected book is unavailable. File does not exist or is not accessible")} ret = {} out = list() @@ -318,7 +325,9 @@ def edit_book_param(param, vals, multi=False): "msg": _("Oops! Selected book is unavailable. File does not exist or is not accessible")} if multi: out.append(ret) - continue + continue + else: + return ret calibre_db.create_functions(config) sort_param = "" try: diff --git a/cps/helper.py b/cps/helper.py index bbfc8268..ba56f506 100644 --- a/cps/helper.py +++ b/cps/helper.py @@ -960,9 +960,8 @@ def do_download_file(book, book_format, client, data, headers): # ToDo Check headers parameter for element in headers: response.headers[element[0]] = element[1] - log.info('Downloading file: \'%s\' by %s', format(os.path.join(filename, book_name + "." + book_format)), + log.info('Downloading file: \'%s\' by %s - %s', format(os.path.join(filename, book_name + "." + book_format)), current_user.name, request.headers.get('X-Forwarded-For', request.remote_addr)) - log.info('Downloading file: {}'.format(os.path.join(filename, book_name + "." + book_format))) return response diff --git a/test/Calibre-Web TestSummary_Linux.html b/test/Calibre-Web TestSummary_Linux.html index dad550db..386fcd1a 100644 --- a/test/Calibre-Web TestSummary_Linux.html +++ b/test/Calibre-Web TestSummary_Linux.html @@ -37,20 +37,20 @@
-

Start Time: 2024-12-15 07:24:54

+

Start Time: 2025-01-03 19:44:59

-

Stop Time: 2024-12-15 14:36:53

+

Stop Time: 2025-01-04 03:03:26

-

Duration: 6h 5 min

+

Duration: 6h 12 min

@@ -234,11 +234,11 @@ - + TestBackupMetadata 21 - 20 - 1 + 21 + 0 0 0 @@ -419,31 +419,11 @@ - +
TestBackupMetadata - test_backup_change_custom_text
- -
- FAIL -
- - - - + PASS @@ -1864,12 +1844,12 @@ AssertionError: None != '人物 *\'(}"' - + TestEditBooksList 19 - 5 - 5 - 9 + 19 + 0 + 0 0 Detail @@ -1878,31 +1858,11 @@ AssertionError: None != '人物 *\'(}"' - +
TestEditBooksList - test_booklist_xss
- -
- ERROR -
- - - - + PASS @@ -1916,386 +1876,110 @@ KeyError: 'newValue' - +
TestEditBooksList - test_bookslist_edit_categories
- -
- ERROR -
- - - - + PASS - +
TestEditBooksList - test_bookslist_edit_comment
- -
- FAIL -
- - - - + PASS - +
TestEditBooksList - test_bookslist_edit_cust_category
- -
- ERROR -
- - - - + PASS - +
TestEditBooksList - test_bookslist_edit_cust_comment
- -
- FAIL -
- - - - + PASS - +
TestEditBooksList - test_bookslist_edit_cust_enum
- -
- ERROR -
- - - - + PASS - +
TestEditBooksList - test_bookslist_edit_cust_float
- -
- FAIL -
- - - - + PASS - +
TestEditBooksList - test_bookslist_edit_cust_int
- -
- ERROR -
- - - - + PASS - +
TestEditBooksList - test_bookslist_edit_cust_ratings
- -
- ERROR -
- - - - + PASS - +
TestEditBooksList - test_bookslist_edit_cust_text
- -
- FAIL -
- - - - + PASS - +
TestEditBooksList - test_bookslist_edit_languages
- -
- ERROR -
- - - - + PASS - +
TestEditBooksList - test_bookslist_edit_publisher
- -
- ERROR -
- - - - + PASS - +
TestEditBooksList - test_bookslist_edit_series
- -
- ERROR -
- - - - + PASS @@ -2336,33 +2020,11 @@ IndexError: list index out of range - +
TestEditBooksList - test_search_books_list
- -
- FAIL -
- - - - + PASS @@ -2399,9 +2061,9 @@ AssertionError: 4 != 5
Traceback (most recent call last):
-  File "/home/ozzie/Development/calibre-web-test/test/test_edit_books_metadata.py", line 220, in test_load_metadata
-    self.assertLessEqual(diff(BytesIO(cover), BytesIO(new_cover), delete_diff_file=True), 0.02)
-AssertionError: 0.02499824076612272 not less than or equal to 0.02
+ File "/home/ozzie/Development/calibre-web-test/test/test_edit_books_metadata.py", line 268, in test_load_metadata + self.assertEqual(1, found) +AssertionError: 1 != 0
@@ -3877,46 +3539,53 @@ AssertionError: 0.02499824076612272 not less than or equal to 0.02 - - _FailedTest + + TestMassEditBooksList + 5 + 4 1 0 0 - 1 - 0 - Detail + Detail - + -
_FailedTest - test_mass_edit_books_list
+
TestMassEditBooksList - test_author_title_combi
+ + PASS + + + + + + +
TestMassEditBooksList - test_invalid_author_title
- ERROR + FAIL
-