Skip to content

Commit

Permalink
Fixes after testrun
Browse files Browse the repository at this point in the history
Code cosmetics
  • Loading branch information
OzzieIsaacs committed Mar 13, 2022
1 parent 3b5e5f9 commit 296f76b
Show file tree
Hide file tree
Showing 5 changed files with 295 additions and 227 deletions.
2 changes: 1 addition & 1 deletion cps/admin.py
Expand Up @@ -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 ""
Expand Down
2 changes: 1 addition & 1 deletion cps/templates/listenmp3.html
Expand Up @@ -134,7 +134,7 @@
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 }}"
};
Expand Down
2 changes: 1 addition & 1 deletion cps/templates/read.html
Expand Up @@ -86,7 +86,7 @@ <h3>{{_('Settings')}}</h3>
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 }}"
Expand Down
17 changes: 9 additions & 8 deletions cps/web.py
Expand Up @@ -26,6 +26,7 @@
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
Expand Down Expand Up @@ -59,6 +60,7 @@
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),
Expand All @@ -72,11 +74,6 @@
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:
Expand Down Expand Up @@ -134,7 +131,7 @@ def get_email_status_json():

@web.route("/ajax/bookmark/<int:book_id>/<book_format>", 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,
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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),
Expand Down

0 comments on commit 296f76b

Please sign in to comment.