Skip to content

Commit

Permalink
Bugfix rename author in book list
Browse files Browse the repository at this point in the history
  • Loading branch information
Ozzie Isaacs committed Jun 18, 2023
1 parent 07d97d1 commit e63a040
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions cps/editbooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ def get_sorted_entry(field, bookid):
if field == 'sort':
return json.dumps({'sort': book.title})
if field == 'author_sort':
return json.dumps({'author_sort': book.author})
return json.dumps({'authors': " & ".join([a.name for a in calibre_db.order_authors([book])])})
return ""


Expand Down Expand Up @@ -1250,13 +1250,14 @@ def handle_author_on_edit(book, author_name, update_stored=True):
# handle author(s)
input_authors, renamed = prepare_authors(author_name)

# change |= modify_database_object(input_authors, book.authors, db.Authors, calibre_db.session, 'author')
# Search for each author if author is in database, if not, author name and sorted author name is generated new
# everything then is assembled for sorted author field in database
sort_authors_list = list()
for inp in input_authors:
stored_author = calibre_db.session.query(db.Authors).filter(db.Authors.name == inp).first()
if not stored_author:
stored_author = helper.get_sorted_author(inp)
stored_author = helper.get_sorted_author(inp.replace('|', ','))
else:
stored_author = stored_author.sort
sort_authors_list.append(helper.get_sorted_author(stored_author))
Expand Down

0 comments on commit e63a040

Please sign in to comment.