From b9536812f4d294fe78bd0c90ac9b53ca1e16ccb1 Mon Sep 17 00:00:00 2001 From: Ozzieisaacs Date: Sun, 22 Nov 2020 09:09:41 +0100 Subject: [PATCH] Fix browser caching problem on change cover --- cps/editbooks.py | 17 ++++++++++------- cps/templates/book_edit.html | 2 +- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/cps/editbooks.py b/cps/editbooks.py index 80cb4dc8..ceccf359 100644 --- a/cps/editbooks.py +++ b/cps/editbooks.py @@ -284,7 +284,7 @@ def delete_book(book_id, book_format, jsonResponse): return redirect(url_for('web.index')) -def render_edit_book(book_id): +def render_edit_book(book_id, cover_edited): calibre_db.update_title_sort(config) cc = calibre_db.session.query(db.Custom_Columns).filter(db.Custom_Columns.datatype.notin_(db.cc_exceptions)).all() book = calibre_db.get_filtered_book(book_id) @@ -307,7 +307,7 @@ def render_edit_book(book_id): kepub_possible=None if config.config_converterpath: for file in book.data: - if file.format.lower() in constants.EXTENSIONS_CONVERT: + if file.format.lower() in constants.EXTENSIONS_CONVERT_FROM: valid_source_formats.append(file.format.lower()) if config.config_kepubifypath and 'epub' in [file.format.lower() for file in book.data]: kepub_possible = True @@ -316,7 +316,7 @@ def render_edit_book(book_id): # Determine what formats don't already exist if config.config_converterpath: - allowed_conversion_formats = constants.EXTENSIONS_CONVERT[:] + allowed_conversion_formats = constants.EXTENSIONS_CONVERT_TO[:] for file in book.data: if file.format.lower() in allowed_conversion_formats: allowed_conversion_formats.remove(file.format.lower()) @@ -325,7 +325,7 @@ def render_edit_book(book_id): return render_title_template('book_edit.html', book=book, authors=author_names, cc=cc, title=_(u"edit metadata"), page="editbook", conversion_formats=allowed_conversion_formats, - config=config, + config=config, cover_edit=cover_edited, source_formats=valid_source_formats) @@ -582,9 +582,10 @@ def upload_cover(request, book): @edit_required def edit_book(book_id): modif_date = False + cover_edited = 0 # Show form if request.method != 'POST': - return render_edit_book(book_id) + return render_edit_book(book_id, cover_edited) # create the function for sorting... calibre_db.update_title_sort(config) @@ -599,6 +600,7 @@ def edit_book(book_id): if upload_cover(request, book) is True: book.has_cover = 1 modif_date = True + cover_edited = uuid4() try: to_save = request.form.to_dict() merge_metadata(to_save, meta) @@ -659,6 +661,7 @@ def edit_book(book_id): if result is True: book.has_cover = 1 modif_date = True + cover_edited = uuid4() else: flash(error, category="error") @@ -710,11 +713,11 @@ def edit_book(book_id): return redirect(url_for('web.show_book', book_id=book.id)) else: flash(_("Metadata successfully updated"), category="success") - return render_edit_book(book_id) + return render_edit_book(book_id, cover_edited) else: calibre_db.session.rollback() flash(error, category="error") - return render_edit_book(book_id) + return render_edit_book(book_id, cover_edited) except Exception as e: log.exception(e) calibre_db.session.rollback() diff --git a/cps/templates/book_edit.html b/cps/templates/book_edit.html index 16c02fae..38d2447d 100644 --- a/cps/templates/book_edit.html +++ b/cps/templates/book_edit.html @@ -3,7 +3,7 @@ {% if book %}
- {{ book.title }} + {{ book.title }}
{% if g.user.role_delete_books() %}