added publisher list in, so publisher in book.html is about done

This commit is contained in:
2020-11-21 17:57:06 +11:00
parent b58b968c66
commit 1edf5082c7
2 changed files with 16 additions and 6 deletions

View File

@@ -16,8 +16,8 @@ ma = Marshmallow(app)
Bootstrap(app) Bootstrap(app)
from author import Author, AuthorForm, AuthorSchema from author import Author, AuthorForm, AuthorSchema
from publisher import Publisher, PublisherForm, PublisherSchema from publisher import Publisher, PublisherForm, PublisherSchema, GetPublishers
from genre import Genre, GenreForm, GenreSchema, GetGenreList from genre import Genre, GenreForm, GenreSchema, GetGenres
from condition import Condition, ConditionForm, ConditionSchema from condition import Condition, ConditionForm, ConditionSchema
from covertype import Covertype, CovertypeForm, CovertypeSchema from covertype import Covertype, CovertypeForm, CovertypeSchema
from owned import Owned, OwnedForm, OwnedSchema from owned import Owned, OwnedForm, OwnedSchema
@@ -168,8 +168,9 @@ def book(id):
book_form.owned.default = book.owned book_form.owned.default = book.owned
book_form.rating.default = book.rating book_form.rating.default = book.rating
book_form.process() book_form.process()
genre_list = GetGenreList() genre_list = GetGenres()
return render_template("book.html", books=book_s, subs=sub_book, book_form=book_form, genre_list=genre_list ) 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 )
@app.route("/", methods=["GET"]) @app.route("/", methods=["GET"])
def main_page(): def main_page():

View File

@@ -1,6 +1,7 @@
{% extends "base.html" %} {% extends "base.html" %}
{% block main_content %} {% block main_content %}
<h3><center>View/Edit Book</center></h1> <h3><center>View/Edit Book</center></h1>
{% set keys = [ 'title', 'author', 'publisher', 'genre', 'owned', 'covertype', 'condition', 'year_published', 'rating', 'notes', 'blurb' ] %} {% set keys = [ 'title', 'author', 'publisher', 'genre', 'owned', 'covertype', 'condition', 'year_published', 'rating', 'notes', 'blurb' ] %}
<div class="container"><div class="row"><form class="form col-lg-12"> <div class="container"><div class="row"><form class="form col-lg-12">
@@ -36,8 +37,16 @@
<a style="color:inherit" href="{{url_for(key, id=-1)}}"><i class="fas fa-plus"></i></a> <a style="color:inherit" href="{{url_for(key, id=-1)}}"><i class="fas fa-plus"></i></a>
</button> </button>
</div> </div>
<span class="form-control col" id="{{key}}[0]">{{books[key][0].name}} <select class="form-control" id="publisher">
</span> {% for pub in publisher_list %}
{% set pname=pub.name %}
<option id="{{books.publisher[0].id}}" value="{{books.publisher[0].id}}"
{% if books.publisher[0].name == pname %}
selected
{% endif %}
>{{pname}}</option>
{% endfor %}
</select>
</div class="row"> </div class="row">
</div class="col-lg-10"> </div class="col-lg-10">
{% elif key == "author" %} {% elif key == "author" %}