1
0
mirror of https://github.com/janeczku/calibre-web synced 2025-09-11 23:36:01 +00:00

Bugfix mass edit books

This commit is contained in:
Ozzie Isaacs
2025-09-08 12:05:59 +02:00
parent d480c55bcb
commit 0d07e445de
3 changed files with 13 additions and 8 deletions

View File

@@ -215,7 +215,8 @@ def table_get_custom_enum(c_id):
@edit_required
def edit_list_book(param):
vals = request.get_json()
ret_value = edit_book_param(param, vals)
multi = vals.get('multi', False) == "True"
ret_value = edit_book_param(param, vals, multi)
if isinstance(ret_value, dict):
return jsonify(ret_value)
else:
@@ -369,9 +370,11 @@ def edit_book_param(param, vals, multi=False):
if handle_title_on_edit(book, vals.get('value', "")):
rename_error = helper.update_dir_structure(book.id, config.get_book_path())
if not rename_error:
calibre_db.session.commit()
ret = {"success":True,
"newValue":book.title}
else:
calibre_db.session.rollback()
ret = {"success":False, "msg":rename_error}
if multi:
out.append(ret)
@@ -387,9 +390,11 @@ def edit_book_param(param, vals, multi=False):
input_authors, __ = handle_author_on_edit(book, vals['value'], vals.get('checkA', None) == True)
rename_error = helper.update_dir_structure(book.id, config.get_book_path(), input_authors[0])
if not rename_error:
calibre_db.session.commit()
ret = {"success":True,
"newValue":' & '.join([author.replace('|', ',') for author in input_authors])}
else:
calibre_db.session.rollback()
ret = {"success":False, "msg":rename_error}
if multi:
out.append(ret)

View File

@@ -471,12 +471,12 @@ def update_dir_structure_file(book_id, calibre_path, original_filepath, new_auth
db_filename,
original_filepath,
path)
new_path = os.path.join(calibre_path, new_author_dir, new_title_dir).replace('\\', '/')
all_new_name = get_valid_filename(local_book.title, chars=42) + ' - ' \
+ get_valid_filename(new_author, chars=42)
# Book folder already moved, only files need to be renamed
renameerror = rename_all_files_on_change(local_book, new_path, new_path, all_new_name)
if not error:
new_path = os.path.join(calibre_path, new_author_dir, new_title_dir).replace('\\', '/')
all_new_name = get_valid_filename(local_book.title, chars=42) + ' - ' \
+ get_valid_filename(new_author, chars=42)
# Book folder already moved, only files need to be renamed
renameerror = rename_all_files_on_change(local_book, new_path, new_path, all_new_name)
if error or renameerror:
return error or renameerror

View File

@@ -1265,7 +1265,7 @@ function bookCheckboxHeader(CheckboxState, text, field_index) {
$.ajax({
method: "post",
url: getPath() + "/ajax/editbooks/" + field_index,
data: JSON.stringify({"pk": result, "field_index": field_index, "value": CheckboxState}),
data: JSON.stringify({"pk": result, "field_index": field_index, "value": CheckboxState, multi: "True"}),
contentType: "application/json; charset=utf-8",
dataType: "json",
error: function (data) {