mirror of
https://github.com/janeczku/calibre-web
synced 2025-10-15 23:57:39 +00:00
Bugfix mass edit books
This commit is contained in:
@@ -215,7 +215,8 @@ def table_get_custom_enum(c_id):
|
|||||||
@edit_required
|
@edit_required
|
||||||
def edit_list_book(param):
|
def edit_list_book(param):
|
||||||
vals = request.get_json()
|
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):
|
if isinstance(ret_value, dict):
|
||||||
return jsonify(ret_value)
|
return jsonify(ret_value)
|
||||||
else:
|
else:
|
||||||
@@ -369,9 +370,11 @@ def edit_book_param(param, vals, multi=False):
|
|||||||
if handle_title_on_edit(book, vals.get('value', "")):
|
if handle_title_on_edit(book, vals.get('value', "")):
|
||||||
rename_error = helper.update_dir_structure(book.id, config.get_book_path())
|
rename_error = helper.update_dir_structure(book.id, config.get_book_path())
|
||||||
if not rename_error:
|
if not rename_error:
|
||||||
|
calibre_db.session.commit()
|
||||||
ret = {"success":True,
|
ret = {"success":True,
|
||||||
"newValue":book.title}
|
"newValue":book.title}
|
||||||
else:
|
else:
|
||||||
|
calibre_db.session.rollback()
|
||||||
ret = {"success":False, "msg":rename_error}
|
ret = {"success":False, "msg":rename_error}
|
||||||
if multi:
|
if multi:
|
||||||
out.append(ret)
|
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)
|
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])
|
rename_error = helper.update_dir_structure(book.id, config.get_book_path(), input_authors[0])
|
||||||
if not rename_error:
|
if not rename_error:
|
||||||
|
calibre_db.session.commit()
|
||||||
ret = {"success":True,
|
ret = {"success":True,
|
||||||
"newValue":' & '.join([author.replace('|', ',') for author in input_authors])}
|
"newValue":' & '.join([author.replace('|', ',') for author in input_authors])}
|
||||||
else:
|
else:
|
||||||
|
calibre_db.session.rollback()
|
||||||
ret = {"success":False, "msg":rename_error}
|
ret = {"success":False, "msg":rename_error}
|
||||||
if multi:
|
if multi:
|
||||||
out.append(ret)
|
out.append(ret)
|
||||||
|
@@ -471,12 +471,12 @@ def update_dir_structure_file(book_id, calibre_path, original_filepath, new_auth
|
|||||||
db_filename,
|
db_filename,
|
||||||
original_filepath,
|
original_filepath,
|
||||||
path)
|
path)
|
||||||
new_path = os.path.join(calibre_path, new_author_dir, new_title_dir).replace('\\', '/')
|
if not error:
|
||||||
all_new_name = get_valid_filename(local_book.title, chars=42) + ' - ' \
|
new_path = os.path.join(calibre_path, new_author_dir, new_title_dir).replace('\\', '/')
|
||||||
+ get_valid_filename(new_author, chars=42)
|
all_new_name = get_valid_filename(local_book.title, chars=42) + ' - ' \
|
||||||
# Book folder already moved, only files need to be renamed
|
+ get_valid_filename(new_author, chars=42)
|
||||||
renameerror = rename_all_files_on_change(local_book, new_path, new_path, all_new_name)
|
# 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:
|
if error or renameerror:
|
||||||
return error or renameerror
|
return error or renameerror
|
||||||
|
@@ -1265,7 +1265,7 @@ function bookCheckboxHeader(CheckboxState, text, field_index) {
|
|||||||
$.ajax({
|
$.ajax({
|
||||||
method: "post",
|
method: "post",
|
||||||
url: getPath() + "/ajax/editbooks/" + field_index,
|
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",
|
contentType: "application/json; charset=utf-8",
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
error: function (data) {
|
error: function (data) {
|
||||||
|
Reference in New Issue
Block a user