From fc12536a83f974b06e40e99abc0acc65407a9763 Mon Sep 17 00:00:00 2001 From: Damien De Paoli Date: Sun, 22 Nov 2020 12:02:01 +1100 Subject: [PATCH] reordered add button to be consistent with author and publisher, then allowed author to be a drop-down with a + or - button as appropriate --- author.py | 3 +++ main.py | 5 +++-- templates/book.html | 45 ++++++++++++++++++++++++++++++++++----------- 3 files changed, 40 insertions(+), 13 deletions(-) diff --git a/author.py b/author.py index c47e316..3b82510 100644 --- a/author.py +++ b/author.py @@ -68,3 +68,6 @@ def author(id): author_form = AuthorForm(request.values, obj=author) message="" return render_template("author.html", author=author, alert=alert, message=message, author_form=author_form) + +def GetAuthors(): + return Author.query.order_by('surname','firstnames').all() diff --git a/main.py b/main.py index 0c13e41..da8dce2 100644 --- a/main.py +++ b/main.py @@ -15,7 +15,7 @@ db = SQLAlchemy(app) ma = Marshmallow(app) Bootstrap(app) -from author import Author, AuthorForm, AuthorSchema +from author import Author, AuthorForm, AuthorSchema, GetAuthors from publisher import Publisher, PublisherForm, PublisherSchema, GetPublishers from genre import Genre, GenreForm, GenreSchema, GetGenres from condition import Condition, ConditionForm, ConditionSchema, GetConditionById @@ -173,9 +173,10 @@ def book(id): book_form.owned.default = book.owned book_form.rating.default = book.rating book_form.process() + author_list = GetAuthors() genre_list = GetGenres() publisher_list = GetPublishers() - return render_template("book.html", books=book_s, subs=sub_book, book_form=book_form, genre_list=genre_list, publisher_list=publisher_list, covertype_list=covertypes ) + return render_template("book.html", books=book_s, subs=sub_book, book_form=book_form, author_list=author_list, publisher_list=publisher_list, genre_list=genre_list ) @app.route("/", methods=["GET"]) def main_page(): diff --git a/templates/book.html b/templates/book.html index b9a2a9e..1ef7bc7 100644 --- a/templates/book.html +++ b/templates/book.html @@ -28,13 +28,13 @@
-
+ {% for auth in author_list %} + {% set aname=auth.surname+", "+auth.firstnames %} + + {% endfor %} + +
{% set cnt.idx = cnt.idx+1 %} {% endfor %} -
+ {% else %}