diff --git a/main.py b/main.py index 747bec9..954167a 100644 --- a/main.py +++ b/main.py @@ -2,7 +2,7 @@ from flask import Flask, render_template, request from flask_sqlalchemy import SQLAlchemy from flask_marshmallow import Marshmallow from flask_bootstrap import Bootstrap -from wtforms import SubmitField, StringField, HiddenField, SelectField, validators, Form +from wtforms import SubmitField, StringField, HiddenField, SelectField, validators from flask_wtf import FlaskForm app = Flask(__name__) @@ -17,7 +17,7 @@ Bootstrap(app) from author import Author, AuthorForm, AuthorSchema from publisher import Publisher, PublisherForm, PublisherSchema -from genre import Genre, GenreForm, GenreSchema +from genre import Genre, GenreForm, GenreSchema, GetGenreList from condition import Condition, ConditionForm, ConditionSchema from covertype import Covertype, CovertypeForm, CovertypeSchema from owned import Owned, OwnedForm, OwnedSchema @@ -164,7 +164,8 @@ def book(id): book_form.owned.default = book.owned book_form.rating.default = book.rating book_form.process() - return render_template("book.html", books=book_s, subs=sub_book, book_form=book_form ) + genre_list = GetGenreList() + return render_template("book.html", books=book_s, subs=sub_book, book_form=book_form, genre_list=genre_list ) @app.route("/", methods=["GET"]) def main_page(): diff --git a/templates/book.html b/templates/book.html index 1853b7d..c085d80 100644 --- a/templates/book.html +++ b/templates/book.html @@ -6,7 +6,26 @@
{% for key in keys %} -{% if key == "condition" or key == "covertype" or key == "owned" or key == "rating" %} + {% if key == "genre" %} +
+ +
+ {% for genre in genre_list %} + {% set gname=genre.name %} +
+ + +
+ {% endfor %} +
+
+{% elif key == "condition" or key == "covertype" or key == "owned" or key == "rating" %}
@@ -56,8 +75,11 @@ {% if books.sub_book|length %}

sub_book is defined: {{books.sub_book}}

{% endif %} + {% if books.subs|length %} +

subs is defined {{ books.subs }}

+ {% endif %} {% if books.loan|length %}

loan is defined: {{books.loan}}

{% endif %} - {{ books.subs }} + {% endblock main_content %}