remove edit buttons on author/publisher, in fact publisher is now a standard field with a BookForm SelectField, and showing, updating publisher works in book.html
This commit is contained in:
11
main.py
11
main.py
@@ -165,8 +165,8 @@ class BookForm(FlaskForm):
|
||||
id = HiddenField()
|
||||
title = StringField('Title:', [validators.DataRequired()])
|
||||
# author built by hand
|
||||
# publiser built by hand
|
||||
# genre built by hand
|
||||
publisher = SelectField( 'publisher', choices=[(c.id, c.name) for c in Publisher.query.order_by('id')] )
|
||||
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')] )
|
||||
@@ -332,11 +332,11 @@ def book(id):
|
||||
message=""
|
||||
book_form = BookForm(request.form)
|
||||
book = Book.query.get(id)
|
||||
if request.method == 'POST' and book_form.validate():
|
||||
if request.method == 'POST':
|
||||
if 'delete' in request.form:
|
||||
alert="danger"
|
||||
message="Sorry, Deleting unsupported at present"
|
||||
else:
|
||||
elif book_form.validate():
|
||||
book.title = request.form['title']
|
||||
book.owned = request.form['owned']
|
||||
book.covertype = request.form['covertype']
|
||||
@@ -349,9 +349,14 @@ def book(id):
|
||||
# process author, genre, publisher & series?, subbooks?, loan?, etc.
|
||||
db.session.commit()
|
||||
message="Successfully Updated Book (id={})".format(id)
|
||||
else:
|
||||
alert="danger"
|
||||
print( book_form)
|
||||
message="Shit broke in update of Book (id={}) {}".format(id, book_form.owned.data)
|
||||
else:
|
||||
book_form=BookForm(request.form)
|
||||
# set defaults for drop-down's based on this book
|
||||
book_form.publisher.default = book.publisher[0].id
|
||||
book_form.condition.default = book.condition
|
||||
book_form.covertype.default = book.covertype
|
||||
book_form.owned.default = book.owned
|
||||
|
||||
Reference in New Issue
Block a user