diff --git a/src/hxbooks/main.py b/src/hxbooks/main.py index 59558bf..d808cd4 100644 --- a/src/hxbooks/main.py +++ b/src/hxbooks/main.py @@ -6,7 +6,7 @@ Provides clean URL structure and integrates with library.py business logic. import traceback from datetime import date -from typing import Annotated, Any +from typing import Annotated, Any, Literal from flask import ( Blueprint, @@ -39,7 +39,7 @@ bp = Blueprint("main", __name__) # Pydantic validation models StrOrNone = Annotated[str | None, BeforeValidator(lambda v: v.strip() or None)] StripStr = Annotated[str, StringConstraints(strip_whitespace=True)] -ISBNOrNone = Annotated[ISBN | None, BeforeValidator(lambda v: v.strip() or None)] +ISBNOrEmpty = Annotated[ISBN | Literal[""], BeforeValidator(lambda v: v.strip() or "")] TextareaList = Annotated[ list[str], BeforeValidator( @@ -57,7 +57,7 @@ IntOrNone = Annotated[int | None, BeforeValidator(lambda v: v.strip() or None)] class BookFormData(BaseModel): title: StripStr = Field(min_length=1) owner: StrOrNone = None - isbn: ISBNOrNone = None + isbn: ISBNOrEmpty = "" authors: TextareaList = Field(default_factory=list) genres: TextareaList = Field(default_factory=list) first_published: IntOrNone = Field(default=None, le=2030) @@ -205,7 +205,7 @@ def create_book() -> ResponseReturnValue: owner_id=owner_id, authors=form_data.authors, genres=form_data.genres, - isbn=str(form_data.isbn) if form_data.isbn else None, + isbn=str(form_data.isbn), publisher=form_data.publisher, edition=form_data.edition, description=form_data.description, @@ -256,7 +256,7 @@ def update_book(book_id: int) -> ResponseReturnValue: owner_id=owner_id, authors=form_data.authors, genres=form_data.genres, - isbn=str(form_data.isbn) if form_data.isbn else None, + isbn=form_data.isbn, publisher=form_data.publisher, edition=form_data.edition, description=form_data.description, diff --git a/src/hxbooks/templates/base.html.j2 b/src/hxbooks/templates/base.html.j2 index 510744a..2c5aa19 100644 --- a/src/hxbooks/templates/base.html.j2 +++ b/src/hxbooks/templates/base.html.j2 @@ -14,8 +14,8 @@ - {# - #} + + {# #} {# @@ -33,7 +33,7 @@ - + {% include 'components/header.html.j2' %} diff --git a/src/hxbooks/templates/components/book_card.html.j2 b/src/hxbooks/templates/components/book_card.html.j2 index bcb8bdc..287c395 100644 --- a/src/hxbooks/templates/components/book_card.html.j2 +++ b/src/hxbooks/templates/components/book_card.html.j2 @@ -1,4 +1,4 @@ -
+
@@ -73,4 +73,4 @@ • {{ book.location_place }} {% endif %}
-
\ No newline at end of file +
\ No newline at end of file