removed clever code around publiseher/author, etc. it was just too cryptic, and it does not need to be so generic

This commit is contained in:
2020-11-21 14:32:38 +11:00
parent 52a75e2d71
commit 9dee77b057
2 changed files with 52 additions and 67 deletions

18
main.py
View File

@@ -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?)