Clean-up book from ArchivedBook on hard-delete.

This change also adds a warning to the hard-delete prompt that deleted
books should first be archived if the Kobo Sync feature is enabled.
An alternative would be to keep a permanent record of hard-deleted
book.
This commit is contained in:
Michael Shavit 2020-01-26 16:20:10 -05:00
parent dc7aaae235
commit f9dbc6bc78
2 changed files with 12 additions and 2 deletions

View File

@ -159,6 +159,7 @@ def delete_book(book_id, book_format):
# delete book from Shelfs, Downloads, Read list # delete book from Shelfs, Downloads, Read list
ub.session.query(ub.BookShelf).filter(ub.BookShelf.book_id == book_id).delete() ub.session.query(ub.BookShelf).filter(ub.BookShelf.book_id == book_id).delete()
ub.session.query(ub.ReadBook).filter(ub.ReadBook.book_id == book_id).delete() ub.session.query(ub.ReadBook).filter(ub.ReadBook.book_id == book_id).delete()
ub.session.query(ub.ArchivedBook).filter(ub.ReadBook.book_id == book_id).delete()
ub.delete_download(book_id) ub.delete_download(book_id)
ub.session.commit() ub.session.commit()
@ -241,6 +242,7 @@ def render_edit_book(book_id):
return render_title_template('book_edit.html', book=book, authors=author_names, cc=cc, return render_title_template('book_edit.html', book=book, authors=author_names, cc=cc,
title=_(u"edit metadata"), page="editbook", title=_(u"edit metadata"), page="editbook",
conversion_formats=allowed_conversion_formats, conversion_formats=allowed_conversion_formats,
config=config,
source_formats=valid_source_formats) source_formats=valid_source_formats)

View File

@ -185,8 +185,16 @@
<span>{{_('Are you really sure?')}}</span> <span>{{_('Are you really sure?')}}</span>
</div> </div>
<div class="modal-body text-center"> <div class="modal-body text-center">
<span>{{_('Book will be deleted from Calibre database')}}</span> <p>
<span>{{_('and from hard disk')}}</span> <span>{{_('Book will be deleted from Calibre database')}}</span>
<span>{{_('and from hard disk')}}</span>
</p>
{% if config.config_kobo_sync %}
<p>
<span>{{_('Important Kobo Note: deleted books will remain on any paired Kobo device.')}}</span>
<span>{{_('Books must first be archived and the device synced before a book can safely be deleted.')}}</span>
</p>
{% endif %}
</div> </div>
<div class="modal-footer"> <div class="modal-footer">