diff --git a/cps/helper.py b/cps/helper.py index 00090e86..7e773a2d 100755 --- a/cps/helper.py +++ b/cps/helper.py @@ -307,12 +307,12 @@ def get_sorted_author(value): return value2 -def delete_book(book, calibrepath, format=None): +def delete_book(book, calibrepath, book_format=None): if "/" in book.path: path = os.path.join(calibrepath, book.path) - if format: + if book_format: for file in os.listdir(path): - if file.upper().endswith("."+format): + if file.upper().endswith("."+book_format): os.remove(os.path.join(path, file)) else: shutil.rmtree(path, ignore_errors=True) diff --git a/cps/templates/book_edit.html b/cps/templates/book_edit.html index 3d575fa9..f299719a 100644 --- a/cps/templates/book_edit.html +++ b/cps/templates/book_edit.html @@ -21,7 +21,7 @@ {% for file in book.data %}

- {{_('Delete')}} + {{_('Delete')}}

{% endfor %} diff --git a/cps/web.py b/cps/web.py index ccdce83b..69d6f1ad 100755 --- a/cps/web.py +++ b/cps/web.py @@ -1476,14 +1476,14 @@ def stats(): categorycounter=categorys, seriecounter=series, title=_(u"Statistics")) -@app.route("/delete///") +@app.route("/delete///") @login_required -def delete_book_format(book_id, format): +def delete_book_format(book_id, book_format): if current_user.role_delete_books(): book = db.session.query(db.Books).filter(db.Books.id == book_id).first() if book: - helper.delete_book(book, config.config_calibre_dir, format=format) - db.session.query(db.Data).filter(db.Data.book == book.id).filter(db.Data.format == format).delete() + helper.delete_book(book, config.config_calibre_dir, book_format=book_format) + db.session.query(db.Data).filter(db.Data.book == book.id).filter(db.Data.format == book_format).delete() db.session.commit() else: # book not found