mirror of
https://github.com/janeczku/calibre-web
synced 2025-10-24 20:07:41 +00:00
Bugfix handle archive bit
This commit is contained in:
17
cps/web.py
17
cps/web.py
@@ -56,6 +56,7 @@ from .redirect import redirect_back
|
||||
from .usermanagement import login_required_if_no_ano
|
||||
from .kobo_sync_status import remove_synced_book
|
||||
from .render_template import render_title_template
|
||||
from .kobo_sync_status import change_archived_books
|
||||
|
||||
feature_support = {
|
||||
'ldap': bool(services.ldap),
|
||||
@@ -190,24 +191,15 @@ def toggle_read(book_id):
|
||||
return "Custom Column No.{} is not existing in calibre database".format(config.config_read_column), 400
|
||||
except (OperationalError, InvalidRequestError) as e:
|
||||
calibre_db.session.rollback()
|
||||
log.error(u"Read status could not set: %e", e)
|
||||
log.error(u"Read status could not set: {}".format(e))
|
||||
return "Read status could not set: {}".format(e), 400
|
||||
return ""
|
||||
|
||||
@web.route("/ajax/togglearchived/<int:book_id>", methods=['POST'])
|
||||
@login_required
|
||||
def toggle_archived(book_id):
|
||||
archived_book = ub.session.query(ub.ArchivedBook).filter(and_(ub.ArchivedBook.user_id == int(current_user.id),
|
||||
ub.ArchivedBook.book_id == book_id)).first()
|
||||
if archived_book:
|
||||
archived_book.is_archived = not archived_book.is_archived
|
||||
archived_book.last_modified = datetime.utcnow()
|
||||
else:
|
||||
archived_book = ub.ArchivedBook(user_id=current_user.id, book_id=book_id)
|
||||
archived_book.is_archived = True
|
||||
ub.session.merge(archived_book)
|
||||
ub.session_commit("Book {} archivebit toggled".format(book_id))
|
||||
if archived_book.is_archived:
|
||||
is_archived = change_archived_books(book_id, message="Book {} archivebit toggled".format(book_id))
|
||||
if is_archived:
|
||||
remove_synced_book(book_id)
|
||||
return ""
|
||||
|
||||
@@ -801,7 +793,6 @@ def list_books():
|
||||
|
||||
if sort == "state":
|
||||
state = json.loads(request.args.get("state", "[]"))
|
||||
# order = [db.Books.timestamp.asc()] if order == "asc" else [db.Books.timestamp.desc()] # ToDo wrong: sort ticked
|
||||
elif sort == "tags":
|
||||
order = [db.Tags.name.asc()] if order == "asc" else [db.Tags.name.desc()]
|
||||
join = db.books_tags_link,db.Books.id == db.books_tags_link.c.book, db.Tags
|
||||
|
||||
Reference in New Issue
Block a user