From 34478079d83755ce843ba200638717929ecc3010 Mon Sep 17 00:00:00 2001 From: Ozzie Isaacs Date: Wed, 9 Mar 2022 14:45:39 +0100 Subject: [PATCH] Prevent local variable 'from_book' referenced before assignment during merge of books Merge books source book: Each book in own row Merge books, sources are deleted before dialog shows up again --- cps/editbooks.py | 2 +- cps/static/js/table.js | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/cps/editbooks.py b/cps/editbooks.py index fcf043a5..483e8a7e 100755 --- a/cps/editbooks.py +++ b/cps/editbooks.py @@ -1263,8 +1263,8 @@ def simulate_merge_list_book(): to_book = calibre_db.get_book(vals[0]).title vals.pop(0) if to_book: + from_book = [] for book_id in vals: - from_book = [] from_book.append(calibre_db.get_book(book_id).title) return json.dumps({'to': to_book, 'from': from_book}) return "" diff --git a/cps/static/js/table.js b/cps/static/js/table.js index dce1d06c..ae8c591b 100644 --- a/cps/static/js/table.js +++ b/cps/static/js/table.js @@ -107,8 +107,9 @@ $(function() { url: window.location.pathname + "/../ajax/simulatemerge", data: JSON.stringify({"Merge_books":selections}), success: function success(booTitles) { + $('#merge_from').empty(); $.each(booTitles.from, function(i, item) { - $("- " + item + "").appendTo("#merge_from"); + $("- " + item + "

").appendTo("#merge_from"); }); $("#merge_to").text("- " + booTitles.to);