mirror of
https://github.com/janeczku/calibre-web
synced 2025-09-12 07:46:01 +00:00
Bugfix mass edit books
This commit is contained in:
@@ -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)
|
||||
|
@@ -471,13 +471,13 @@ def update_dir_structure_file(book_id, calibre_path, original_filepath, new_auth
|
||||
db_filename,
|
||||
original_filepath,
|
||||
path)
|
||||
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
|
||||
return False
|
||||
|
@@ -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) {
|
||||
|
Reference in New Issue
Block a user