From 296f76b5fb96c6a0747af49fba81d01514ab2092 Mon Sep 17 00:00:00 2001 From: Ozzie Isaacs Date: Sun, 13 Mar 2022 10:23:13 +0100 Subject: [PATCH] Fixes after testrun Code cosmetics --- cps/admin.py | 2 +- cps/templates/listenmp3.html | 2 +- cps/templates/read.html | 2 +- cps/web.py | 17 +- test/Calibre-Web TestSummary_Linux.html | 503 ++++++++++++++---------- 5 files changed, 297 insertions(+), 229 deletions(-) diff --git a/cps/admin.py b/cps/admin.py index 60a674e8..3d4ca609 100644 --- a/cps/admin.py +++ b/cps/admin.py @@ -499,7 +499,7 @@ def edit_list_user(param): else: return _("Parameter not found"), 400 except Exception as ex: - log.debug_or_exception(ex) + log.error_or_exception(ex) return str(ex), 400 ub.session_commit() return "" diff --git a/cps/templates/listenmp3.html b/cps/templates/listenmp3.html index 7da62a20..2067bf38 100644 --- a/cps/templates/listenmp3.html +++ b/cps/templates/listenmp3.html @@ -134,7 +134,7 @@ window.calibre = { filePath: "{{ url_for('static', filename='js/libs/') }}", cssPath: "{{ url_for('static', filename='css/') }}", bookUrl: "{{ url_for('static', filename=mp3file) }}/", - bookmarkUrl: "{{ url_for('web.bookmark', book_id=mp3file, book_format=audioformat.upper()) }}", + bookmarkUrl: "{{ url_for('web.set_bookmark', book_id=mp3file, book_format=audioformat.upper()) }}", bookmark: "{{ bookmark.bookmark_key if bookmark != None }}", useBookmarks: "{{ g.user.is_authenticated | tojson }}" }; diff --git a/cps/templates/read.html b/cps/templates/read.html index 1766eb1b..f69d662f 100644 --- a/cps/templates/read.html +++ b/cps/templates/read.html @@ -86,7 +86,7 @@ window.calibre = { filePath: "{{ url_for('static', filename='js/libs/') }}", cssPath: "{{ url_for('static', filename='css/') }}", - bookmarkUrl: "{{ url_for('web.bookmark', book_id=bookid, book_format='EPUB') }}", + bookmarkUrl: "{{ url_for('web.set_bookmark', book_id=bookid, book_format='EPUB') }}", bookUrl: "{{ url_for('web.serve_book', book_id=bookid, book_format='epub', anyname='file.epub') }}", bookmark: "{{ bookmark.bookmark_key if bookmark != None }}", useBookmarks: "{{ g.user.is_authenticated | tojson }}" diff --git a/cps/web.py b/cps/web.py index e3ad4719..8c057b9d 100644 --- a/cps/web.py +++ b/cps/web.py @@ -26,6 +26,7 @@ import json import mimetypes import chardet # dependency of requests import copy +from functools import wraps from babel.dates import format_date from babel import Locale as LC @@ -59,6 +60,7 @@ from .kobo_sync_status import remove_synced_book from .render_template import render_title_template from .kobo_sync_status import change_archived_books + feature_support = { 'ldap': bool(services.ldap), 'goodreads': bool(services.goodreads_support), @@ -72,11 +74,6 @@ except ImportError: feature_support['oauth'] = False oauth_check = {} -try: - from functools import wraps -except ImportError: - pass # We're not using Python 3 - try: from natsort import natsorted as sort except ImportError: @@ -134,7 +131,7 @@ def get_email_status_json(): @web.route("/ajax/bookmark//", methods=['POST']) @login_required -def bookmark(book_id, book_format): +def set_bookmark(book_id, book_format): bookmark_key = request.form["bookmark"] ub.session.query(ub.Bookmark).filter(and_(ub.Bookmark.user_id == int(current_user.id), ub.Bookmark.book_id == book_id, @@ -642,7 +639,8 @@ def render_read_books(page, are_read, as_xml=False, order=None): column=config.config_read_column), category="error") return redirect(url_for("web.index")) - # ToDo: Handle error Case for opds + return [] # ToDo: Handle error Case for opds + if as_xml: return entries, pagination else: @@ -809,6 +807,7 @@ def list_books(): and_(ub.ReadBook.user_id == int(current_user.id), ub.ReadBook.book_id == db.Books.id))) else: + read_column = "" try: read_column = db.cc_classes[config.config_read_column] books = (calibre_db.session.query(db.Books, read_column.value, ub.ArchivedBook.is_archived) @@ -1725,12 +1724,14 @@ 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(_(u"Oops! Selected book title is unavailable. File does not exist or is not accessible"), category="error") log.debug(u"Oops! Selected book title is unavailable. File does not exist or is not accessible") return redirect(url_for("web.index")) - # check if book has bookmark + # check if book has a bookmark bookmark = None if current_user.is_authenticated: bookmark = ub.session.query(ub.Bookmark).filter(and_(ub.Bookmark.user_id == int(current_user.id), diff --git a/test/Calibre-Web TestSummary_Linux.html b/test/Calibre-Web TestSummary_Linux.html index 5daf8267..580cf3c9 100644 --- a/test/Calibre-Web TestSummary_Linux.html +++ b/test/Calibre-Web TestSummary_Linux.html @@ -37,20 +37,20 @@
-

Start Time: 2022-03-02 20:56:18

+

Start Time: 2022-03-12 22:57:13

-

Stop Time: 2022-03-03 01:48:44

+

Stop Time: 2022-03-13 03:46:17

-

Duration: 4h 5 min

+

Duration: 4h 0 min

@@ -725,13 +725,13 @@ TestEditAdditionalBooks - 19 17 + 16 0 0 - 2 + 1 - Detail + Detail @@ -863,42 +863,7 @@ - - -
TestEditAdditionalBooks - test_writeonly_calibre_database
- - -
- SKIP -
- - - - - - - - - - -
TestEditAdditionalBooks - test_writeonly_path
- - PASS - - - - - +
TestEditAdditionalBooks - test_xss_author_edit
@@ -907,7 +872,7 @@ - +
TestEditAdditionalBooks - test_xss_comment_edit
@@ -916,7 +881,7 @@ - +
TestEditAdditionalBooks - test_xss_custom_comment_edit
@@ -1867,7 +1832,7 @@ AssertionError: 0.0 not greater than 0.02
Traceback (most recent call last):
   File "/home/ozzie/Development/calibre-web-test/test/test_edit_ebooks_gdrive.py", line 947, in test_watch_metadata
     self.assertNotIn('series', book)
-AssertionError: 'series' unexpectedly found in {'id': 5, 'reader': [], 'title': 'testbook', 'author': ['John Döe'], 'rating': 0, 'languages': ['English'], 'identifier': [], 'cover': '/cover/5?edit=22ded0fa-26b4-429d-81fc-bc75707c4e4c', 'tag': [], 'publisher': ['Randomhäus'], 'pubdate': 'Jan 19, 2017', 'comment': 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit.Aenean commodo ligula eget dolor.Aenean massa.Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem.Nulla consequat massa quis enim.Donec pede justo, fringilla vel, aliquet nec, vulputate', 'add_shelf': [], 'del_shelf': [], 'edit_enable': True, 'kindle': None, 'kindlebtn': None, 'download': ['EPUB (6.7 kB)'], 'read': False, 'archived': False, 'series_all': 'Book 1 of test', 'series_index': '1', 'series': 'test', 'cust_columns': []}
+AssertionError: 'series' unexpectedly found in {'id': 5, 'reader': [], 'title': 'testbook', 'author': ['John Döe'], 'rating': 0, 'languages': ['English'], 'identifier': [], 'cover': '/cover/5?edit=4a23d5c4-e97a-42e1-bd43-351fb1de43df', 'tag': [], 'publisher': ['Randomhäus'], 'pubdate': 'Jan 19, 2017', 'comment': 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit.Aenean commodo ligula eget dolor.Aenean massa.Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem.Nulla consequat massa quis enim.Donec pede justo, fringilla vel, aliquet nec, vulputate', 'add_shelf': [], 'del_shelf': [], 'edit_enable': True, 'kindle': None, 'kindlebtn': None, 'download': ['EPUB (6.7 kB)'], 'read': False, 'archived': False, 'series_all': 'Book 1 of test', 'series_index': '1', 'series': 'test', 'cust_columns': []}
@@ -3172,11 +3137,11 @@ AssertionError: 'series' unexpectedly found in {'id': 5, 're - + TestReader 5 - 5 - 0 + 4 + 1 0 0 @@ -3213,11 +3178,35 @@ AssertionError: 'series' unexpectedly found in {'id': 5, 're - +
TestReader - test_sound_listener
- PASS + +
+ FAIL +
+ + + + @@ -3232,12 +3221,12 @@ AssertionError: 'series' unexpectedly found in {'id': 5, 're - - TestReconnect - 1 + + TestReadOnlyDatabase 1 0 0 + 1 0 Detail @@ -3246,7 +3235,65 @@ AssertionError: 'series' unexpectedly found in {'id': 5, 're - + + +
TestReadOnlyDatabase - test_readonly_path
+ + +
+ ERROR +
+ + + + + + + + + + + TestReconnect + 1 + 1 + 0 + 0 + 0 + + Detail + + + + + +
TestReconnect - test_reconnect_endpoint
@@ -3264,13 +3311,13 @@ AssertionError: 'series' unexpectedly found in {'id': 5, 're 0 0 - Detail + Detail - +
TestRegister - test_forgot_password
@@ -3279,7 +3326,7 @@ AssertionError: 'series' unexpectedly found in {'id': 5, 're - +
TestRegister - test_illegal_email
@@ -3288,7 +3335,7 @@ AssertionError: 'series' unexpectedly found in {'id': 5, 're - +
TestRegister - test_limit_domain
@@ -3297,7 +3344,7 @@ AssertionError: 'series' unexpectedly found in {'id': 5, 're - +
TestRegister - test_register_no_server
@@ -3306,7 +3353,7 @@ AssertionError: 'series' unexpectedly found in {'id': 5, 're - +
TestRegister - test_registering_only_email
@@ -3315,7 +3362,7 @@ AssertionError: 'series' unexpectedly found in {'id': 5, 're - +
TestRegister - test_registering_user
@@ -3324,7 +3371,7 @@ AssertionError: 'series' unexpectedly found in {'id': 5, 're - +
TestRegister - test_registering_user_fail
@@ -3333,7 +3380,7 @@ AssertionError: 'series' unexpectedly found in {'id': 5, 're - +
TestRegister - test_user_change_password
@@ -3351,13 +3398,13 @@ AssertionError: 'series' unexpectedly found in {'id': 5, 're 0 0 - Detail + Detail - +
TestReverseProxy - test_logout
@@ -3366,7 +3413,7 @@ AssertionError: 'series' unexpectedly found in {'id': 5, 're - +
TestReverseProxy - test_move_page
@@ -3375,7 +3422,7 @@ AssertionError: 'series' unexpectedly found in {'id': 5, 're - +
TestReverseProxy - test_reverse_about
@@ -3393,13 +3440,13 @@ AssertionError: 'series' unexpectedly found in {'id': 5, 're 0 1 - Detail + Detail - +
TestShelf - test_access_shelf
@@ -3408,7 +3455,7 @@ AssertionError: 'series' unexpectedly found in {'id': 5, 're - +
TestShelf - test_add_shelf_from_search
@@ -3417,7 +3464,7 @@ AssertionError: 'series' unexpectedly found in {'id': 5, 're - +
TestShelf - test_adv_search_shelf
@@ -3426,7 +3473,7 @@ AssertionError: 'series' unexpectedly found in {'id': 5, 're - +
TestShelf - test_arrange_shelf
@@ -3435,7 +3482,7 @@ AssertionError: 'series' unexpectedly found in {'id': 5, 're - +
TestShelf - test_create_public_shelf
@@ -3444,7 +3491,7 @@ AssertionError: 'series' unexpectedly found in {'id': 5, 're - +
TestShelf - test_create_public_shelf_no_permission
@@ -3453,7 +3500,7 @@ AssertionError: 'series' unexpectedly found in {'id': 5, 're - +
TestShelf - test_delete_book_of_shelf
@@ -3462,7 +3509,7 @@ AssertionError: 'series' unexpectedly found in {'id': 5, 're - +
TestShelf - test_private_shelf
@@ -3471,7 +3518,7 @@ AssertionError: 'series' unexpectedly found in {'id': 5, 're - +
TestShelf - test_public_private_shelf
@@ -3480,7 +3527,7 @@ AssertionError: 'series' unexpectedly found in {'id': 5, 're - +
TestShelf - test_public_shelf
@@ -3489,7 +3536,7 @@ AssertionError: 'series' unexpectedly found in {'id': 5, 're - +
TestShelf - test_rename_shelf
@@ -3498,7 +3545,7 @@ AssertionError: 'series' unexpectedly found in {'id': 5, 're - +
TestShelf - test_shelf_action_non_shelf_edit_role
@@ -3507,7 +3554,7 @@ AssertionError: 'series' unexpectedly found in {'id': 5, 're - +
TestShelf - test_shelf_anonymous
@@ -3516,19 +3563,19 @@ AssertionError: 'series' unexpectedly found in {'id': 5, 're - +
TestShelf - test_shelf_database_change
- SKIP + SKIP
-