style: format backend with black

Also drops the session-sliding comment in login_required.
This commit is contained in:
2026-10-02 14:46:16 -05:00
parent 2512c67893
commit 63c9991421
14 changed files with 320 additions and 82 deletions
+11 -2
View File
@@ -1,4 +1,5 @@
"""Notes slice: a per-book reading journal. Ownership is always derived through books.user_id."""
from flask import Blueprint, g, jsonify
from auth import login_required
@@ -22,7 +23,12 @@ def to_json(row: dict) -> dict:
def _require_book(book_id: int) -> None:
if query_one("SELECT 1 FROM books WHERE id = %s AND user_id = %s", (book_id, g.user_id)) is None:
if (
query_one(
"SELECT 1 FROM books WHERE id = %s AND user_id = %s", (book_id, g.user_id)
)
is None
):
raise ApiError(404, "Book not found")
@@ -42,7 +48,10 @@ def list_notes(book_id: int):
def add_note(book_id: int):
_require_book(book_id)
body = text(json_body({"body"}), "body", MAX_BODY)
row = query_one(f"INSERT INTO notes AS n (book_id, body) VALUES (%s, %s) RETURNING {NOTE_COLUMNS}", (book_id, body))
row = query_one(
f"INSERT INTO notes AS n (book_id, body) VALUES (%s, %s) RETURNING {NOTE_COLUMNS}",
(book_id, body),
)
return jsonify(to_json(row)), 201