From 606c3615cff73d68bb87c44067457dc7c2f25d65 Mon Sep 17 00:00:00 2001 From: Damien De Paoli Date: Wed, 25 Nov 2020 17:53:05 +1100 Subject: [PATCH] books_for_series now deals with sub books (hiding ability to reorder them in series), and disables first book (parent or normal) and last book (normal or parent of last sub-book) --- main.py | 2 +- templates/book.html | 1 + templates/books_for_series.html | 40 ++++++++++++++++++++++----------- 3 files changed, 29 insertions(+), 14 deletions(-) diff --git a/main.py b/main.py index b2de82a..5b84584 100644 --- a/main.py +++ b/main.py @@ -109,7 +109,7 @@ class BookSchema(ma.SQLAlchemyAutoSchema): publisher = ma.Nested(PublisherSchema, many=True) genre = ma.Nested(GenreSchema, many=True) loan = ma.Nested(LoanSchema, many=True) - series = ma.Nested(Book_Series_LinkSchema, many=True) + series = ma.Nested(SeriesSchema, many=True) parent_ref = ma.Nested(Book_Sub_Book_LinkSchema, many=True) child_ref = ma.Nested(Book_Sub_Book_LinkSchema, many=True) class Meta: model = Book diff --git a/templates/book.html b/templates/book.html index b826bc3..2ba4327 100644 --- a/templates/book.html +++ b/templates/book.html @@ -4,6 +4,7 @@

View/Edit Book

{% set keys = [ 'title', 'author', 'publisher', 'genre', 'owned', 'covertype', 'condition', 'year_published', 'rating', 'notes', 'blurb' ] %} + {{books.owned}}
{% for key in keys %}
diff --git a/templates/books_for_series.html b/templates/books_for_series.html index 4bed8ed..e5c0273 100644 --- a/templates/books_for_series.html +++ b/templates/books_for_series.html @@ -6,23 +6,36 @@ {% for book in books %} - {% if SeriesBookNum( series.id, book.id ) == 1 %} - {% set ds="disabled" %} - {% endif %} - - {% if SeriesBookNum( series.id, book.id ) == series.num_books %} - {% set de="disabled" %} - {% endif %} - - {% if book.sub_book_num is defined %} -     {{book.title}} - {% else %} - {{book.title}} + {% if book.parent_ref|length %} + {% set style="visibility: hidden" %} {% endif %} + + + {{book.title}} {% for s in book.series %} - {{ SeriesBookNum( s.id, book.id ) }} of {{s.title}}
+ {% if not book.child_ref|length %} + {{ SeriesBookNum( s.id, book.id ) }} of {{s.title}}
+ {% endif %} + {% if SeriesBookNum( s.id, book.id ) == 1 %} + + {% endif %} + {% if SeriesBookNum( s.id, book.id ) == s.num_books %} + + {% endif %} {% endfor %} @@ -39,3 +52,4 @@ "columnDefs": [ { "type": "num", "targets": 1 } ] } ); } ); +