Exemple #1
0
def create_artist_submission():
    error = False
    artist = Artist()
    try:
        artist.name = request.form['name']
        artist.city = request.form['city']
        artist.state = request.form['state']
        artist.phone = request.form['phone'],
        artist.facebook_link = request.form['facebook_link'],
        artist.genres = request.form.getlist('genres'),
        artist.image_link = request.form['image_link']
        artist.website = request.form['website']
        artist.seeking_venue = True if 'seeking_venue' in request.form else False
        artist.seeking_description = request.form['seeking_description']
        db.session.add(artist)
        db.session.commit()
    except:
        error = True
        db.session.rollback()
        print(sys.exc_info())
    if error:
        flash('An error ' + request.form['name'] + ' could not be listed.')
    if not error:
        flash(request.form['name'] + ' was successfully added!')
    return render_template('pages/home.html')