Fix for #1123 (mature content is visible in shelfs)

pull/1131/head
Ozzieisaacs 5 years ago
parent 32e818af6a
commit 8ad84a7ceb

@ -30,6 +30,7 @@ from sqlalchemy.sql.expression import func, or_, and_
from . import logger, ub, searched_ids, db
from .web import render_title_template
from .helper import common_filters
shelf = Blueprint('shelf', __name__)
@ -281,16 +282,10 @@ def show_shelf(shelf_type, shelf_id):
if shelf:
page = "shelf.html" if shelf_type == 1 else 'shelfdown.html'
books_in_shelf = ub.session.query(ub.BookShelf).filter(ub.BookShelf.shelf == shelf_id).order_by(
ub.BookShelf.order.asc()).all()
for book in books_in_shelf:
cur_book = db.session.query(db.Books).filter(db.Books.id == book.book_id).first()
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()
books_in_shelf = ub.session.query(ub.BookShelf).filter(ub.BookShelf.shelf == shelf_id)\
.order_by(ub.BookShelf.order.asc()).all()
books_list = [ b.book_id for b in books_in_shelf]
result = db.session.query(db.Books).filter(db.Books.id.in_(books_list)).filter(common_filters()).all()
return render_title_template(page, entries=result, title=_(u"Shelf: '%(name)s'", name=shelf.name),
shelf=shelf, page="shelf")
else:
@ -322,9 +317,8 @@ def order_shelf(shelf_id):
if shelf:
books_in_shelf2 = ub.session.query(ub.BookShelf).filter(ub.BookShelf.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).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()
return render_title_template('shelf_order.html', entries=result,
title=_(u"Change order of Shelf: '%(name)s'", name=shelf.name),
shelf=shelf, page="shelforder")

Loading…
Cancel
Save