diff --git a/main.py b/main.py index d97def8..4819b3a 100644 --- a/main.py +++ b/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 diff --git a/templates/book.html b/templates/book.html index 096eefe..98e3b30 100644 --- a/templates/book.html +++ b/templates/book.html @@ -32,24 +32,6 @@ {% endfor %} - {% elif key == "publisher" %} -