Exemple #1
0
def create_artist_submission():
    """
  create artist on form submission
  """
    try:
        request.get_data()
        genres = request.form.getlist('genres')
        artist_dict = request.form.to_dict()
        seeking_venue = artist_dict['seeking_venue'] == "True"
        artist = Artist(name=artist_dict['name'], city=artist_dict['city'], state=artist_dict['state'],\
                      phone=artist_dict['phone'],\
                      facebook_link=artist_dict['facebook_link'],\
                      website_link=artist_dict['website_link'], image_link=artist_dict['image_link'],\
                      seeking_venue=seeking_venue, seeking_description=artist_dict['seeking_description'])
        artist.create(genres)
        flash('artist ' + request.form['name'] + ' was successfully listed!')
    except Exception as e:
        print("Error while creating new artist: ", e)
        print(traceback.format_exc())
        flash('An error occurred. artist ' + request.form['name'] +
              ' could not be listed.')
        abort(500)

    return render_template('pages/home.html')