diff --git a/main.py b/main.py index 954167a..41a8ded 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 +from wtforms import SubmitField, StringField, HiddenField, SelectField, IntegerField, TextAreaField, validators from flask_wtf import FlaskForm app = Flask(__name__) @@ -96,14 +96,18 @@ class BookSchema(ma.SQLAlchemyAutoSchema): # To be completed # class BookForm(FlaskForm): - # I think I'll have to skip setting default on create, and using jquery to - # change it when I create the from? (or maybe I could use a default=set_me - # in the line below, then when I set create set_me = book.condition before - # bf=BookForm() - condition = SelectField( 'condition', choices=[(c.id, c.name) for c in Condition.query.order_by('id')] ) - covertype = SelectField( 'covertype', choices=[(c.id, c.name) for c in Covertype.query.order_by('id')] ) + id = HiddenField() + title = StringField('Title:', [validators.DataRequired()]) + # author built by hand + # publiser built by hand + # genre built by hand owned = SelectField( 'owned', choices=[(c.id, c.name) for c in Owned.query.order_by('id')] ) + covertype = SelectField( 'covertype', choices=[(c.id, c.name) for c in Covertype.query.order_by('id')] ) + condition = SelectField( 'condition', choices=[(c.id, c.name) for c in Condition.query.order_by('id')] ) + year_published = IntegerField('Year Published:', [validators.NumberRange(min=1900, max=2100)] ) rating = SelectField( 'rating', choices=[(c.id, c.name) for c in Rating.query.order_by('id')] ) + notes = TextAreaField('Notes:') + blurb = TextAreaField('Blurb:') ### DDP: do I need many=True on Author as books have many authors? (or in BookSchema declaration above?) diff --git a/templates/book.html b/templates/book.html index dfa89c7..95793bb 100644 --- a/templates/book.html +++ b/templates/book.html @@ -1,77 +1,58 @@ {% extends "base.html" %} {% block main_content %} +
sub_book is defined: {{books.sub_book}}
{% endif %}