fixed up using selects before the app was ready, something that happens in the newer gunicorn but seemingly not flask? also removed compress at least for Dev testing

This commit is contained in:
2023-06-11 00:28:30 +10:00
parent 07d713da15
commit 4223b81641

20
main.py
View File

@@ -5,7 +5,7 @@ from flask_marshmallow import Marshmallow
from flask_bootstrap import Bootstrap from flask_bootstrap import Bootstrap
from wtforms import SubmitField, StringField, HiddenField, SelectField, IntegerField, TextAreaField, validators from wtforms import SubmitField, StringField, HiddenField, SelectField, IntegerField, TextAreaField, validators
from flask_wtf import FlaskForm from flask_wtf import FlaskForm
from flask_compress import Compress #from flask_compress import Compress
from status import st, Status from status import st, Status
# for ldap auth # for ldap auth
from flask_ldap3_login import LDAP3LoginManager from flask_ldap3_login import LDAP3LoginManager
@@ -49,7 +49,7 @@ ldap_manager = LDAP3LoginManager(app) # Setup a LDAP3 Login Manager.
login_manager.login_view = "login" # default login route, failed with url_for, so hard-coded login_manager.login_view = "login" # default login route, failed with url_for, so hard-coded
# enable compression for http / speed # enable compression for http / speed
Compress(app) #Compress(app)
################################# Now, import non-book classes ################################### ################################# Now, import non-book classes ###################################
from author import Author, AuthorForm, AuthorSchema, GetAuthors from author import Author, AuthorForm, AuthorSchema, GetAuthors
@@ -213,12 +213,12 @@ class BookForm(FlaskForm):
title = StringField('Title:', [validators.DataRequired()]) title = StringField('Title:', [validators.DataRequired()])
# author built by hand # author built by hand
# genre built by hand # genre built by hand
publisher = SelectField( 'publisher', choices=[(c.id, c.name) for c in Publisher.query.order_by('name')] ) publisher = SelectField( 'publisher' )
owned = SelectField( 'owned', choices=[(c.id, c.name) for c in Owned.query.order_by('id')] ) owned = SelectField( 'owned' )
covertype = SelectField( 'covertype', choices=[(c.id, c.name) for c in Covertype.query.order_by('id')] ) covertype = SelectField( 'covertype' )
condition = SelectField( 'condition', choices=[(c.id, c.name) for c in Condition.query.order_by('id')] ) condition = SelectField( 'condition' )
year_published = IntegerField('Year Published:', validators=[validators.DataRequired(), validators.NumberRange(min=1900, max=2100)] ) year_published = IntegerField('Year Published:', validators=[validators.DataRequired(), validators.NumberRange(min=1900, max=2100)] )
rating = SelectField( 'rating', choices=[(c.id, c.name) for c in Rating.query.order_by('id')] ) rating = SelectField( 'rating' )
notes = TextAreaField('Notes:') notes = TextAreaField('Notes:')
blurb = TextAreaField('Blurb:') blurb = TextAreaField('Blurb:')
submit = SubmitField('Save' ) submit = SubmitField('Save' )
@@ -494,6 +494,11 @@ def remove_sub_book():
@login_required @login_required
def new_book(): def new_book():
form = BookForm(request.form) form = BookForm(request.form)
form.publisher.choices = [(c.id, c.name) for c in Publisher.query.order_by('name')]
form.owned.choices=[(c.id, c.name) for c in Owned.query.order_by('id')]
form.covertype.choices=[(c.id, c.name) for c in Covertype.query.order_by('id')]
form.condition.choices=[(c.id, c.name) for c in Condition.query.order_by('id')]
form.rating.choices=[(c.id, c.name) for c in Rating.query.order_by('id')]
page_title='Create new Book' page_title='Create new Book'
author_list = GetAuthors() author_list = GetAuthors()
genre_list = GetGenres() genre_list = GetGenres()
@@ -781,7 +786,6 @@ def books_on_shelf():
ordered_books=[] ordered_books=[]
handle_parent=[] handle_parent=[]
currently_owned = Owned.query.filter(Owned.name=='Currently Owned').one() currently_owned = Owned.query.filter(Owned.name=='Currently Owned').one()
print( f"co={currently_owned}" )
for b in books: for b in books:
if b.series: if b.series:
# find biggest Series # find biggest Series