Skip to content

Commit 36b3033

Browse files
committed
fix: resolve undefined variables and missing schema decorators in app.py
1 parent 643f6da commit 36b3033

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

‎backend/app.py‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1333,7 +1333,7 @@ def add_to_library(validated_data):
13331333
from error_responses import handle_exception
13341334

13351335
try:
1336-
1336+
current_user_id = get_jwt_identity()
13371337
if str(validated_data.user_id) != str(current_user_id):
13381338
return unauthorized_access_error("Cannot access another user's library")
13391339

@@ -1506,7 +1506,7 @@ def _get_yearly_stats(user_id, year):
15061506
def update_library_item(item_id, validated_data):
15071507
"""Update a library item (e.g. move to different shelf)."""
15081508
try:
1509-
1509+
current_user_id = get_jwt_identity()
15101510
item = ShelfItem.query.with_for_update().get(item_id)
15111511
if not item:
15121512
return not_found_error("Library item")
@@ -2108,7 +2108,7 @@ def verify_auth_session():
21082108
@validate_schema(SetGoalRequest)
21092109
def set_reading_goal(validated_data):
21102110
"""Set or update annual reading goal."""
2111-
2111+
current_user_id = get_jwt_identity()
21122112
if str(validated_data.user_id) != str(current_user_id):
21132113
return forbidden_error("Unauthorized")
21142114

@@ -2226,7 +2226,7 @@ def get_leaderboard():
22262226
@validate_schema(CollectionRequest)
22272227
def create_collection(validated_data):
22282228
"""Create a new collection."""
2229-
2229+
current_user_id = get_jwt_identity()
22302230
if str(validated_data.user_id) != str(current_user_id):
22312231
return forbidden_error("Unauthorized")
22322232

@@ -2296,6 +2296,7 @@ def update_collection(collection_id, validated_data):
22962296
"""Update a collection."""
22972297

22982298
try:
2299+
current_user_id = get_jwt_identity()
22992300
collection = Collection.query.get(collection_id)
23002301
if not collection:
23012302
return jsonify({"error": "Collection not found"}), 404
@@ -2349,10 +2350,12 @@ def delete_collection(collection_id):
23492350

23502351
@app.route('/api/v1/collections/<int:collection_id>/books', methods=['POST'])
23512352
@jwt_required()
2352-
def add_book_to_collection(collection_id):
2353+
@validate_schema(AddToCollectionRequest)
2354+
def add_book_to_collection(collection_id, validated_data):
23532355
"""Add a book to a collection."""
23542356

23552357
try:
2358+
current_user_id = get_jwt_identity()
23562359
collection = Collection.query.get(collection_id)
23572360
if not collection:
23582361
return jsonify({"error": "Collection not found"}), 404

0 commit comments

Comments
 (0)