diff --git a/cps/shelf.py b/cps/shelf.py index 597578fe..be102ea9 100644 --- a/cps/shelf.py +++ b/cps/shelf.py @@ -22,6 +22,7 @@ from __future__ import division, print_function, unicode_literals from datetime import datetime +import sys from flask import Blueprint, request, flash, redirect, url_for from flask_babel import gettext as _ @@ -338,15 +339,17 @@ def delete_shelf(shelf_id): flash(_(u"Settings DB is not Writeable"), category="error") return redirect(url_for('web.index')) - -@shelf.route("/shelf/", defaults={'shelf_type': 1}) -@shelf.route("/shelf//") +@shelf.route("/simpleshelf/") @login_required_if_no_ano -def show_shelf(shelf_type, shelf_id): - page_no = 0 - offset = 0 - order = None - return render_show_shelf(shelf_type, shelf_id, page_no, offset, order) +def show_simpleshelf(shelf_id): + return render_show_shelf(2, shelf_id, 1, None) + +@shelf.route("/shelf/", defaults={"sort_param": "order", 'page': 1}) +@shelf.route("/shelf//", defaults={'page': 1}) +@shelf.route("/shelf///") +@login_required_if_no_ano +def show_shelf(shelf_id, sort_param, page): + return render_show_shelf(1, shelf_id, page, sort_param) @shelf.route("/shelf/order/", methods=["GET", "POST"]) @@ -379,21 +382,30 @@ def order_shelf(shelf_id): shelf=shelf, page="shelforder") -def render_show_shelf(shelf_id, shelf_type, page_no, offset, order): +def render_show_shelf(shelf_type, shelf_id, page_no, sort_param): shelf = ub.session.query(ub.Shelf).filter(ub.Shelf.id == shelf_id).first() # check user is allowed to access shelf if shelf and check_shelf_view_permissions(shelf): - page = "shelf.html" if shelf_type == 1 else 'shelfdown.html' - result, __, pagination = calibre_db.fill_indexpage(page_no, 0, + if shelf_type == 1: + page = "shelf.html" + pagesize = 0 + order = [ub.BookShelf.order.asc()] + else: + pagesize = sys.maxsize + page = 'shelfdown.html' + order = [ub.BookShelf.order.asc()] + + result, __, pagination = calibre_db.fill_indexpage(page_no, pagesize, db.Books, ub.BookShelf.shelf == shelf_id, - [ub.BookShelf.order.asc()], + order, ub.BookShelf,ub.BookShelf.book_id == db.Books.id) # delete chelf entries where book is not existent anymore, can happen if book is deleted outside calibre-web - wrong_entries = calibre_db.session.query(ub.BookShelf).join(db.Books, ub.BookShelf.book_id == db.Books.id, - isouter=True).filter(db.Books.id == None).all() + wrong_entries = calibre_db.session.query(ub.BookShelf)\ + .join(db.Books, ub.BookShelf.book_id == db.Books.id, isouter=True)\ + .filter(db.Books.id == None).all() for entry in wrong_entries: log.info('Not existing book {} in {} deleted'.format(entry.book_id, shelf)) try: @@ -403,8 +415,12 @@ def render_show_shelf(shelf_id, shelf_type, page_no, offset, order): ub.session.rollback() flash(_(u"Settings DB is not Writeable"), category="error") - return render_title_template(page, entries=result, title=_(u"Shelf: '%(name)s'", name=shelf.name), - shelf=shelf, page="shelf") + return render_title_template(page, + entries=result, + pagination=pagination, + title=_(u"Shelf: '%(name)s'", name=shelf.name), + shelf=shelf, + page="shelf") else: flash(_(u"Error opening shelf. Shelf does not exist or is not accessible"), category="error") return redirect(url_for("web.index")) diff --git a/cps/templates/shelf.html b/cps/templates/shelf.html index 75e369ed..f7e3c1ae 100644 --- a/cps/templates/shelf.html +++ b/cps/templates/shelf.html @@ -3,31 +3,28 @@

{{title}}

{% if g.user.role_download() %} - {{ _('Download') }} + {{ _('Download') }} {% endif %} {% if g.user.is_authenticated %} {% if (g.user.role_edit_shelfs() and shelf.is_public ) or not shelf.is_public %}
{{ _('Delete this Shelf') }}
{{ _('Edit Shelf') }} {% if entries.__len__() %} - {{ _('Change order') }} + {% endif %} {% endif %} {% endif %} -
{% for entry in entries %}
diff --git a/cps/web.py b/cps/web.py index cd4787f4..4baf82cb 100644 --- a/cps/web.py +++ b/cps/web.py @@ -421,7 +421,7 @@ def render_books_list(data, sort, book_id, page): elif data == "language": return render_language_books(page, book_id, order) elif data == "archived": - return render_archived_books(page, order) + return render_archived_books(page, book_id, order) elif data == "search": term = (request.args.get('query') or '') offset = int(int(config.config_books_per_page) * (page - 1)) @@ -430,8 +430,6 @@ def render_books_list(data, sort, book_id, page): term = json.loads(flask_session['query']) offset = int(int(config.config_books_per_page) * (page - 1)) return render_adv_search_results(term, offset, order, config.config_books_per_page) - elif data == "shelf": - return shelf.show_shelf(1, book_id) else: website = data or "newest" entries, random, pagination = calibre_db.fill_indexpage(page, 0, db.Books, True, order) diff --git a/optional-requirements.txt b/optional-requirements.txt index acb99c76..5087f4fa 100644 --- a/optional-requirements.txt +++ b/optional-requirements.txt @@ -1,7 +1,7 @@ # GDrive Integration google-api-python-client==1.7.11,<1.8.0 gevent>=1.2.1,<20.6.0 -greenlet>=0.4.12,<0.5.0 +greenlet>=0.4.12,<0.4.17 httplib2>=0.9.2,<0.18.0 oauth2client>=4.0.0,<4.1.4 uritemplate>=3.0.0,<3.1.0