def create_show_submission(): # called to create new shows in the db, upon submitting new show listing form # TODO: insert form data as a new Show record in the db, instead form = ShowForm() created = False if form.validate_on_submit(): try: new_show = Show(start_time=form.start_time.data) new_show.venue = form.venue.data new_show.artist = form.artist.data db.session.add(new_show) db.session.commit() # on successful db insert, flash success created = True flash("Show was successfully listed!") except: print(sys.exc_info()) finally: db.session.close() if created: return redirect(url_for("index")) # TODO: on unsuccessful db insert, flash an error instead. flash("An error occurred. Show could not be listed.") return render_template("forms/new_show.html", form=form)