Пример #1
0
def create_artist_submission():
    artist_form = ArtistForm(request.form)

    try:
        new_artist = Artist(name=artist_form.name.data,
                            genres=','.join(artist_form.genres.data),
                            city=artist_form.city.data,
                            state=artist_form.state.data,
                            phone=artist_form.phone.data,
                            facebook_link=artist_form.facebook_link.data,
                            image_link=artist_form.image_link.data)

        if not new_artist.isExists():
            new_artist.add()
            flash('Artist ' + request.form['name'] +
                  ' was successfully listed!')
        else:
            flash('Artist with a Name: {} , City: {} , and State: {} already exists! New record not inserted'.\
                    format(request.form['name'], request.form['city'], request.form['state']))

    except Exception as ex:
        flash('An error occurred. Artist ' + request.form['name'] +
              ' could not be listed.')

    return render_template('pages/home.html')
Пример #2
0
Файл: main.py Проект: vi-v/Lyre
def put_song_in_artist(song):
    if song.artist.lower() not in artist_map:
        artist = Artist(song.artist)
        artist.add(song)
        artist_map[song.artist.lower()] = artist
    else:
        artist = artist_map[song.artist.lower()]
        artist.add(song)
Пример #3
0
def create_artist_submission():
    artist_form = ArtistForm(request.form)
    try:
        new_artist = Artist(name=artist_form.name.data,
                            genres=','.join(artist_form.genres.data),
                            city=artist_form.city.data,
                            state=artist_form.state.data,
                            phone=artist_form.phone.data,
                            facebook_link=artist_form.facebook_link.data,
                            image_link=artist_form.image_link.data)
        new_artist.add()
        # on successful db insert, flash success
        flash('Artist ' + request.form['name'] + ' was successfully listed!')
    except Exception as ex:
        flash('An error occurred. Artist ' + request.form['name'] +
              ' could not be listed.')
        print(ex)
    return render_template('pages/home.html')
Пример #4
0
def create_artist_submission():
    # called upon submitting the new artist listing 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

    form = ArtistForm(request.form)
    try:
        artist = Artist()
        form.populate_obj(artist)

        artist.add()
        # on successful db insert, flash success
        flash('Artist ' + request.form['name'] + ' was successfully listed!')
    # TODO: on unsuccessful db insert, flash an error instead.
    # e.g., flash('An error occurred. Artist ' + data.name + ' could not be listed.')
    except:
        flash('An error occurred. Artist could not be listed.')
    response = recent_venue_artist()
    return render_template('pages/home.html', results=response)
Пример #5
0
Файл: main.py Проект: vi-v/Lyre
def put_album_in_artist(album):
    if album.artist.lower() not in artist_map:
        artist = Artist(album.artist)
        artist.add(album)
        artist_map[album.artist.lower()] = artist