From b9c942befc176317eec09a576cb96b5e76898c8d Mon Sep 17 00:00:00 2001 From: Ozzie Isaacs Date: Fri, 31 Mar 2023 07:48:18 +0200 Subject: [PATCH] Fix for 'NoneType' object has no attribute 'author_sort' while trying to read a book (#2733) --- cps/db.py | 2 -- cps/web.py | 3 ++- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/cps/db.py b/cps/db.py index 8cc48e1d..1bbcfb6f 100644 --- a/cps/db.py +++ b/cps/db.py @@ -829,8 +829,6 @@ class CalibreDB: # Orders all Authors in the list according to authors sort def order_authors(self, entries, list_return=False, combined=False): - # entries_copy = copy.deepcopy(entries) - # entries_copy =[] for entry in entries: if combined: sort_authors = entry.Books.author_sort.split('&') diff --git a/cps/web.py b/cps/web.py index 7c3a1477..2192941e 100755 --- a/cps/web.py +++ b/cps/web.py @@ -1516,7 +1516,6 @@ def profile(): @viewer_required def read_book(book_id, book_format): book = calibre_db.get_filtered_book(book_id) - book.ordered_authors = calibre_db.order_authors([book], False) if not book: flash(_("Oops! Selected book is unavailable. File does not exist or is not accessible"), @@ -1524,6 +1523,8 @@ def read_book(book_id, book_format): log.debug("Selected book is unavailable. File does not exist or is not accessible") return redirect(url_for("web.index")) + book.ordered_authors = calibre_db.order_authors([book], False) + # check if book has a bookmark bookmark = None if current_user.is_authenticated: