1
0
mirror of https://github.com/janeczku/calibre-web.git synced 2024-11-26 08:51:05 +02:00

Handle sorting of hidden books #1123

Prevent downloading of covers from hidden books
This commit is contained in:
Ozzieisaacs 2020-02-09 14:31:42 +01:00
parent 50ba2e329a
commit ab24ed8088
3 changed files with 24 additions and 13 deletions

View File

@ -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,

View File

@ -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")

View File

@ -5,19 +5,19 @@
<div>{{_('Drag \'n drop to rearrange order')}}</div>
<div id="sortTrue" class="list-group">
{% for entry in entries %}
<div id="{{entry.id}}" class="list-group-item">
<div id="{{entry['id']}}" class="list-group-item">
<div class="row">
<div class="col-lg-2 col-sm-4 hidden-xs">
<img class="cover-height" src="{{ url_for('web.get_cover', book_id=entry.id) }}">
<img class="cover-height" src="{{ url_for('web.get_cover', book_id=entry['id']) }}">
</div>
<div class="col-lg-10 col-sm-8 col-xs-12">
{{entry.title}}
{% if entry.series|length > 0 %}
{{entry['title']}}
{% if entry['series']|length > 0 %}
<br>
{{entry.series_index}} - {{entry.series[0].name}}
{{entry['series_index']}} - {{entry['series'][0].name}}
{% endif %}
<br>
{% for author in entry.authors %}
{% for author in entry['authors'] %}
{{author.name.replace('|',',')}}
{% if not loop.last %}
&amp;