예제 #1
0
def songs_change_name(song_id):

    song = Song.query.get(song_id)
    artist_id = Song.find_artist_for_song(song)
    artist = Artist.query.get(artist_id)
    form = ChangeSongForm(obj=song)  #the form prefilled with the song

    if not form.validate():
        return render_template("songs/change.html",
                               song=song,
                               artist=artist,
                               form=form)

    return render_template("songs/change.html",
                           song=song,
                           artist=artist,
                           form=SongForm(obj=song))
예제 #2
0
def change_form(song_id):
    song = Song.query.get(song_id)
    artist_id = Song.find_artist_for_song(song)
    artist = Artist.query.get(artist_id)
    form = ChangeSongForm(obj=song)  #the form prefilled with the song

    if not form.validate():
        return render_template("songs/change.html",
                               form=form,
                               song=song,
                               artist=artist,
                               song_error="")

    song.songname = form.songname.data
    song.description = form.description.data
    db.session().commit()

    return redirect(url_for("songs_index"))