diff --git a/cps/helper.py b/cps/helper.py index 6e6c1895..ec5628b3 100644 --- a/cps/helper.py +++ b/cps/helper.py @@ -455,7 +455,7 @@ def get_cover_on_failure(use_generic_cover): return None def get_book_cover(book_id): - book = db.session.query(db.Books).filter(db.Books.id == book_id).first() + book = db.session.query(db.Books).filter(db.Books.id == book_id).filter(common_filters()).first() return get_book_cover_internal(book, use_generic_cover_on_failure=True) def get_book_cover_with_uuid(book_uuid, diff --git a/cps/shelf.py b/cps/shelf.py index 9d52434d..75789367 100644 --- a/cps/shelf.py +++ b/cps/shelf.py @@ -291,9 +291,11 @@ def show_shelf(shelf_type, shelf_id): if cur_book: result.append(cur_book) else: - log.info('Not existing book %s in %s deleted', book.book_id, shelf) - ub.session.query(ub.BookShelf).filter(ub.BookShelf.book_id == book.book_id).delete() - ub.session.commit() + cur_book = db.session.query(db.Books).filter(db.Books.id == book.book_id).first() + if not cur_book: + log.info('Not existing book %s in %s deleted', book.book_id, shelf) + ub.session.query(ub.BookShelf).filter(ub.BookShelf.book_id == book.book_id).delete() + ub.session.commit() return render_title_template(page, entries=result, title=_(u"Shelf: '%(name)s'", name=shelf.name), shelf=shelf, page="shelf") else: @@ -327,9 +329,18 @@ def order_shelf(shelf_id): .order_by(ub.BookShelf.order.asc()).all() for book in books_in_shelf2: cur_book = db.session.query(db.Books).filter(db.Books.id == book.book_id).filter(common_filters()).first() - result.append(cur_book) - #books_list = [ b.book_id for b in books_in_shelf2] - #result = db.session.query(db.Books).filter(db.Books.id.in_(books_list)).filter(common_filters()).all() + if cur_book: + result.append({'title':cur_book.title, + 'id':cur_book.id, + 'author':cur_book.authors, + 'series':cur_book.series, + 'series_index':cur_book.series_index}) + else: + cur_book = db.session.query(db.Books).filter(db.Books.id == book.book_id).first() + result.append({'title':_('Hidden Book'), + 'id':cur_book.id, + 'author':[], + 'series':[]}) return render_title_template('shelf_order.html', entries=result, title=_(u"Change order of Shelf: '%(name)s'", name=shelf.name), shelf=shelf, page="shelforder") diff --git a/cps/templates/shelf_order.html b/cps/templates/shelf_order.html index 77192c8c..0094fb31 100644 --- a/cps/templates/shelf_order.html +++ b/cps/templates/shelf_order.html @@ -5,19 +5,19 @@
{{_('Drag \'n drop to rearrange order')}}
{% for entry in entries %} -
+
- {{entry.title}} - {% if entry.series|length > 0 %} + {{entry['title']}} + {% if entry['series']|length > 0 %}
- {{entry.series_index}} - {{entry.series[0].name}} + {{entry['series_index']}} - {{entry['series'][0].name}} {% endif %}
- {% for author in entry.authors %} + {% for author in entry['authors'] %} {{author.name.replace('|',',')}} {% if not loop.last %} &