def create_show_submission(): show_form = ShowForm(request.form) try: show = Show(artist_id=show_form.artist_id.data, venue_id=show_form.venue_id.data, start_time=show_form.start_time.data) show.add() # on successful db insert, flash success flash('Show was successfully listed!') except Exception as e: flash('An error occurred. Show could not be listed.') return render_template('pages/home.html')
def create_show_submission(): show_form = ShowForm(request.form) # TODO: insert form data as a new Venue record in the db, instead # TODO: modify data to be the data object returned from db insertion try: new_show = Show(artist_id=show_form.artist_id.data, venue_id=show_form.venue_id.data, start_time=show_form.start_time.data) new_show.add() # on successful db insert, flash success flash('Show was successfully listed!') except Exception as e: flash('An error occurred could not be listed.') print(e) return render_template('pages/home.html')
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 artist_id = request.form.get('artist_id') venue_id = request.form.get('venue_id') start_time = request.form.get('start_time') show = Show(artist_id=artist_id, venue_id=venue_id, start_time=start_time) try: show.add() flash('Show was successfully listed!') except: db.session.rollback() flash('An error occurred. Show could not be listed.') # on successful db insert, flash success #flash('Show was successfully listed!') # TODO: on unsuccessful db insert, flash an error instead. # e.g., flash('An error occurred. Show could not be listed.') # see: http://flask.pocoo.org/docs/1.0/patterns/flashing/ return render_template('pages/home.html')
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(request.form) try: show = Show(artist_id=form.artist_id.data, venue_id=form.venue_id.data, start_time=form.start_time.data) show.add() # on successful db insert, flash success flash('Show was successfully listed!') # TODO: on unsuccessful db insert, flash an error instead. # e.g., flash('An error occurred. Show could not be listed.') # see: http://flask.pocoo.org/docs/1.0/patterns/flashing/ except: flash('An error occurred. Show could not be listed.') response = recent_venue_artist() return render_template('pages/home.html', results=response)
def create_show_submission(): show_form = ShowForm(request.form) try: show = Show(artist_id=show_form.artist_id.data, venue_id=show_form.venue_id.data, start_time=show_form.start_time.data) if show.start_time is None: flash( 'Show could not be listed. Please make sure that a Show Start Time is in a format YYYY-MM-DD HH:MM:SS.' ) return render_template('pages/home.html') if not show.isExists(): show.add() flash('Show was successfully listed!') else: flash('Show for this artist / venue / time already exists!') except Exception as e: flash('An error occurred. Show could not be listed.') return render_template('pages/home.html')