mirror of
https://github.com/janeczku/calibre-web
synced 2024-12-25 17:40:31 +00:00
Merge remote-tracking branch 'kobo/shelves' into Develop
# Conflicts: # cps/kobo.py # cps/shelf.py
This commit is contained in:
commit
e29f17ac46
@ -82,7 +82,7 @@ SIDEBAR_RATING = 1 << 13
|
||||
SIDEBAR_FORMAT = 1 << 14
|
||||
SIDEBAR_ARCHIVED = 1 << 15
|
||||
|
||||
ADMIN_USER_ROLES = sum(r for r in ALL_ROLES.values()) & ~ROLE_EDIT_SHELFS & ~ROLE_ANONYMOUS
|
||||
ADMIN_USER_ROLES = sum(r for r in ALL_ROLES.values()) & ~ROLE_ANONYMOUS
|
||||
ADMIN_USER_SIDEBAR = (SIDEBAR_ARCHIVED << 1) - 1
|
||||
|
||||
UPDATE_STABLE = 0 << 0
|
||||
|
@ -181,7 +181,7 @@ def delete_book(book_id, book_format):
|
||||
# delete book from Shelfs, Downloads, Read list
|
||||
ub.session.query(ub.BookShelf).filter(ub.BookShelf.book_id == book_id).delete()
|
||||
ub.session.query(ub.ReadBook).filter(ub.ReadBook.book_id == book_id).delete()
|
||||
ub.session.query(ub.ArchivedBook).filter(ub.ReadBook.book_id == book_id).delete()
|
||||
ub.session.query(ub.ArchivedBook).filter(ub.ArchivedBook.book_id == book_id).delete()
|
||||
ub.delete_download(book_id)
|
||||
ub.session.commit()
|
||||
|
||||
|
15
cps/kobo.py
15
cps/kobo.py
@ -407,10 +407,8 @@ def HandleTagCreate():
|
||||
log.debug("Received malformed v1/library/tags request.")
|
||||
abort(400, description="Malformed tags POST request. Data is missing 'Name' or 'Items' field")
|
||||
|
||||
# ToDO: Names are not unique ! -> filter only private shelfs
|
||||
shelf = ub.session.query(ub.Shelf).filter(and_(ub.Shelf.name) == name, ub.Shelf.user_id ==
|
||||
current_user.id).one_or_none() # ToDO: shouldn't it ) at the end
|
||||
|
||||
shelf = ub.session.query(ub.Shelf).filter(ub.Shelf.name == name, ub.Shelf.user_id ==
|
||||
current_user.id).one_or_none()
|
||||
if shelf and not shelf_lib.check_shelf_edit_permissions(shelf):
|
||||
abort(401, description="User is unauthaurized to edit shelf.")
|
||||
|
||||
@ -428,7 +426,7 @@ def HandleTagCreate():
|
||||
|
||||
@kobo.route("/v1/library/tags/<tag_id>", methods=["DELETE", "PUT"])
|
||||
def HandleTagUpdate(tag_id):
|
||||
shelf = ub.session.query(ub.Shelf).filter(and_(ub.Shelf.uuid) == tag_id,
|
||||
shelf = ub.session.query(ub.Shelf).filter(ub.Shelf.uuid == tag_id,
|
||||
ub.Shelf.user_id == current_user.id).one_or_none()
|
||||
if not shelf:
|
||||
log.debug("Received Kobo tag update request on a collection unknown to CalibreWeb")
|
||||
@ -489,7 +487,7 @@ def HandleTagAddItem(tag_id):
|
||||
log.debug("Received malformed v1/library/tags/<tag_id>/items/delete request.")
|
||||
abort(400, description="Malformed tags POST request. Data is missing 'Items' field")
|
||||
|
||||
shelf = ub.session.query(ub.Shelf).filter(and_(ub.Shelf.uuid) == tag_id,
|
||||
shelf = ub.session.query(ub.Shelf).filter(ub.Shelf.uuid == tag_id,
|
||||
ub.Shelf.user_id == current_user.id).one_or_none()
|
||||
if not shelf:
|
||||
log.debug("Received Kobo request on a collection unknown to CalibreWeb")
|
||||
@ -500,7 +498,7 @@ def HandleTagAddItem(tag_id):
|
||||
|
||||
items_unknown_to_calibre = add_items_to_shelf(items, shelf)
|
||||
if items_unknown_to_calibre:
|
||||
log.debug("Received request to add an unknown book to a collecition. Silently ignoring item.")
|
||||
log.debug("Received request to add an unknown book to a collection. Silently ignoring item.")
|
||||
|
||||
ub.session.merge(shelf)
|
||||
ub.session.commit()
|
||||
@ -605,8 +603,7 @@ def create_kobo_tag(shelf):
|
||||
book = db.session.query(db.Books).filter(db.Books.id == book_shelf.book_id).one_or_none()
|
||||
if not book:
|
||||
log.info(u"Book (id: %s) in BookShelf (id: %s) not found in book database", book_shelf.book_id, shelf.id)
|
||||
# ToDo shouldn't it continue?
|
||||
return None
|
||||
continue
|
||||
tag["Items"].append(
|
||||
{
|
||||
"RevisionId": book.uuid,
|
||||
|
@ -24,7 +24,7 @@ import signal
|
||||
import socket
|
||||
|
||||
try:
|
||||
from gevent.pywsgi import WSGIServer
|
||||
from gevent.pywtsgi import WSGIServer
|
||||
from gevent.pool import Pool
|
||||
from gevent import __version__ as _version
|
||||
VERSION = 'Gevent ' + _version
|
||||
|
@ -21,6 +21,7 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from __future__ import division, print_function, unicode_literals
|
||||
from datetime import datetime
|
||||
|
||||
from flask import Blueprint, request, flash, redirect, url_for
|
||||
from flask_babel import gettext as _
|
||||
@ -90,6 +91,7 @@ def add_to_shelf(shelf_id, book_id):
|
||||
maxOrder = maxOrder[0]
|
||||
|
||||
shelf.books.append(ub.BookShelf(shelf=shelf.id, book_id=book_id, order=maxOrder + 1))
|
||||
shelf.last_modified = datetime.utcnow()
|
||||
ub.session.merge(shelf)
|
||||
ub.session.commit()
|
||||
if not xhr:
|
||||
@ -141,6 +143,7 @@ def search_to_shelf(shelf_id):
|
||||
for book in books_for_shelf:
|
||||
maxOrder = maxOrder + 1
|
||||
shelf.books.append(ub.BookShelf(shelf=shelf.id, book_id=book, order=maxOrder))
|
||||
shelf.last_modified = datetime.utcnow()
|
||||
ub.session.merge(shelf)
|
||||
ub.session.commit()
|
||||
flash(_(u"Books have been added to shelf: %(sname)s", sname=shelf.name), category="success")
|
||||
@ -179,6 +182,7 @@ def remove_from_shelf(shelf_id, book_id):
|
||||
return "Book already removed from shelf", 410
|
||||
|
||||
ub.session.delete(book_shelf)
|
||||
shelf.last_modified = datetime.utcnow()
|
||||
ub.session.commit()
|
||||
|
||||
if not xhr:
|
||||
@ -269,6 +273,7 @@ def edit_shelf(shelf_id):
|
||||
|
||||
if is_shelf_name_unique:
|
||||
shelf.name = to_save["title"]
|
||||
shelf.last_modified = datetime.utcnow()
|
||||
if "is_public" in to_save:
|
||||
shelf.is_public = 1
|
||||
else:
|
||||
@ -289,7 +294,7 @@ def delete_shelf_helper(cur_shelf):
|
||||
shelf_id = cur_shelf.id
|
||||
ub.session.delete(cur_shelf)
|
||||
ub.session.query(ub.BookShelf).filter(ub.BookShelf.shelf == shelf_id).delete()
|
||||
ub.session.add(ub.ShelfArchive(uuid=cur_shelf.uuid, user_id=cur_shelf.uuid))
|
||||
ub.session.add(ub.ShelfArchive(uuid=cur_shelf.uuid, user_id=cur_shelf.user_id))
|
||||
ub.session.commit()
|
||||
log.info("successfully deleted %s", cur_shelf)
|
||||
|
||||
@ -342,6 +347,7 @@ def order_shelf(shelf_id):
|
||||
for book in books_in_shelf:
|
||||
setattr(book, 'order', to_save[str(book.book_id)])
|
||||
counter += 1
|
||||
# if order diffrent from before -> shelf.last_modified = datetime.utcnow()
|
||||
ub.session.commit()
|
||||
|
||||
shelf = ub.session.query(ub.Shelf).filter(ub.Shelf.id == shelf_id).first()
|
||||
|
@ -213,7 +213,7 @@
|
||||
</div>
|
||||
|
||||
<div class="modal-footer">
|
||||
<a href="{{ url_for('editbook.delete_book', book_id=book.id) }}" class="btn btn-danger">{{_('Delete')}}</a>
|
||||
<a href="{{ url_for('editbook.delete_book', book_id=book.id) }}" id="delete_confirm" class="btn btn-danger">{{_('Delete')}}</a>
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal">{{_('Cancel')}}</button>
|
||||
</div>
|
||||
</div>
|
||||
@ -313,7 +313,7 @@
|
||||
});
|
||||
function removeIdentifierLine(el) {
|
||||
$(el).parent().parent().remove();
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
<script src="{{ url_for('static', filename='js/libs/typeahead.bundle.js') }}"></script>
|
||||
|
Loading…
Reference in New Issue
Block a user