From 761d2af391dda1bfee38dd2858f4f8f5eb1f756e Mon Sep 17 00:00:00 2001 From: Damien De Paoli Date: Sat, 7 Nov 2020 13:03:10 +1100 Subject: [PATCH] first pass at using jinja2 to make an edit form dynamically, its a bit hit and miss :( --- templates/books.html | 71 ++++++++++++++++++++++++++++++-------------- 1 file changed, 49 insertions(+), 22 deletions(-) diff --git a/templates/books.html b/templates/books.html index aa21326..e1d4af3 100644 --- a/templates/books.html +++ b/templates/books.html @@ -1,16 +1,16 @@ - - - - + + + + - - - - - - - + + + + + + + {% if books is not mapping %}

All Books

@@ -44,22 +44,49 @@ {% else %} -

Book

-

{{books.title}}, {{ books.author[0]['surname'] }}, {{books.author[0]['firstnames']}}

- {% if books.sub_book is defined %} -

sub_book is defined: {{books.sub_book}}

- {% endif %} +

View/Edit Book

+ {% set keys = [ 'title', 'author', 'publisher', '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 %} + + + {% endfor %} + {% endfor %} + {% else %} + {% if key == "notes" or key == "blurb" %} + + {% else %} + + {% endif %} + {% endif %} +
+
+ {% endfor %} +
+
+
+ {% if books.sub_book is defined %} +

sub_book is defined: {{books.sub_book}}

+ {% endif %} {% endif %} - - + + - +