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