|
|
@ -407,7 +407,7 @@ def HandleTagCreate():
|
|
|
|
log.debug("Received malformed v1/library/tags request.")
|
|
|
|
log.debug("Received malformed v1/library/tags request.")
|
|
|
|
abort(400, description="Malformed tags POST request. Data is missing 'Name' or 'Items' field")
|
|
|
|
abort(400, description="Malformed tags POST request. Data is missing 'Name' or 'Items' field")
|
|
|
|
|
|
|
|
|
|
|
|
shelf = ub.session.query(ub.Shelf).filter(and_(ub.Shelf.name) == name, ub.Shelf.user_id ==
|
|
|
|
shelf = ub.session.query(ub.Shelf).filter(ub.Shelf.name == name, ub.Shelf.user_id ==
|
|
|
|
current_user.id).one_or_none()
|
|
|
|
current_user.id).one_or_none()
|
|
|
|
if shelf and not shelf_lib.check_shelf_edit_permissions(shelf):
|
|
|
|
if shelf and not shelf_lib.check_shelf_edit_permissions(shelf):
|
|
|
|
abort(401, description="User is unauthaurized to edit shelf.")
|
|
|
|
abort(401, description="User is unauthaurized to edit shelf.")
|
|
|
@ -426,7 +426,7 @@ def HandleTagCreate():
|
|
|
|
|
|
|
|
|
|
|
|
@kobo.route("/v1/library/tags/<tag_id>", methods=["DELETE", "PUT"])
|
|
|
|
@kobo.route("/v1/library/tags/<tag_id>", methods=["DELETE", "PUT"])
|
|
|
|
def HandleTagUpdate(tag_id):
|
|
|
|
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()
|
|
|
|
ub.Shelf.user_id == current_user.id).one_or_none()
|
|
|
|
if not shelf:
|
|
|
|
if not shelf:
|
|
|
|
log.debug("Received Kobo tag update request on a collection unknown to CalibreWeb")
|
|
|
|
log.debug("Received Kobo tag update request on a collection unknown to CalibreWeb")
|
|
|
@ -487,7 +487,7 @@ def HandleTagAddItem(tag_id):
|
|
|
|
log.debug("Received malformed v1/library/tags/<tag_id>/items/delete request.")
|
|
|
|
log.debug("Received malformed v1/library/tags/<tag_id>/items/delete request.")
|
|
|
|
abort(400, description="Malformed tags POST request. Data is missing 'Items' field")
|
|
|
|
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()
|
|
|
|
ub.Shelf.user_id == current_user.id).one_or_none()
|
|
|
|
if not shelf:
|
|
|
|
if not shelf:
|
|
|
|
log.debug("Received Kobo request on a collection unknown to CalibreWeb")
|
|
|
|
log.debug("Received Kobo request on a collection unknown to CalibreWeb")
|
|
|
@ -498,7 +498,7 @@ def HandleTagAddItem(tag_id):
|
|
|
|
|
|
|
|
|
|
|
|
items_unknown_to_calibre = add_items_to_shelf(items, shelf)
|
|
|
|
items_unknown_to_calibre = add_items_to_shelf(items, shelf)
|
|
|
|
if items_unknown_to_calibre:
|
|
|
|
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.merge(shelf)
|
|
|
|
ub.session.commit()
|
|
|
|
ub.session.commit()
|
|
|
@ -600,7 +600,7 @@ def create_kobo_tag(shelf):
|
|
|
|
book = db.session.query(db.Books).filter(db.Books.id == book_shelf.book_id).one_or_none()
|
|
|
|
book = db.session.query(db.Books).filter(db.Books.id == book_shelf.book_id).one_or_none()
|
|
|
|
if not book:
|
|
|
|
if not book:
|
|
|
|
log.info(u"Book (id: %s) in BookShelf (id: %s) not found in book database", book_shelf.book_id, shelf.id)
|
|
|
|
log.info(u"Book (id: %s) in BookShelf (id: %s) not found in book database", book_shelf.book_id, shelf.id)
|
|
|
|
return None
|
|
|
|
continue
|
|
|
|
tag["Items"].append(
|
|
|
|
tag["Items"].append(
|
|
|
|
{
|
|
|
|
{
|
|
|
|
"RevisionId": book.uuid,
|
|
|
|
"RevisionId": book.uuid,
|
|
|
|