diff --git a/main.py b/main.py index 192cd02..005010d 100644 --- a/main.py +++ b/main.py @@ -91,16 +91,14 @@ class Genre_LstSchema(ma.SQLAlchemyAutoSchema): class BookSchema(ma.SQLAlchemyAutoSchema): author = ma.Nested(AuthorSchema, many=True) - publisher = ma.Nested(PublisherSchema) + publisher = ma.Nested(PublisherSchema, many=True) + genre = ma.Nested(Genre_LstSchema, many=True) class Meta: model = Book include_relationships = True load_instance = True ### DDP: do I need many=True on Author as books have many authors? (or in BookSchema declaration above?) -author_schema = AuthorSchema(many=True) -publisher_schema = PublisherSchema() -genre_schema = Genre_LstSchema(many=True) book_schema = BookSchema() ####################################### ROUTES ####################################### diff --git a/templates/books.html b/templates/books.html index e166e61..9af902f 100644 --- a/templates/books.html +++ b/templates/books.html @@ -44,36 +44,42 @@ {% else %} -

View/Edit Book

- {% set keys = [ 'title', 'author', 'publisher', 'owned', 'covertype', 'condition', 'year_published', 'rating', 'notes', 'blurb' ] %} +

View/Edit Book

+ {% set keys = [ 'title', 'author', 'publisher', 'genre', 'owned', 'covertype', 'condition', 'year_published', 'rating', 'notes', 'blurb' ] %}
-
-
+
+ {% for key in keys %} -
- -
+
+ +
{% if books[key] is iterable and books[key] is not string %} + {% for objects in books[key] %} + {% for attr in objects %} - - + {% if attr != "id" %} + + {% endif %} {% endfor %} + {% endfor %} +
+ +
{% else %} {% if key == "notes" or key == "blurb" %} - + {% else %} - + {% endif %} {% endif %} -
+
{% endfor %}
- {{books.genre}} {% if books.sub_book is defined %}

sub_book is defined: {{books.sub_book}}

{% endif %}