def update_album(id):
    artist_id = request.form["artist_id"]
    artist = artist_repository.select(artist_id)
    title = request.form["title"]
    quantity = request.form["quantity"]
    album = Album(title, artist, quantity, id)
    album_repository.update(album)
    return redirect("/albums")
Ejemplo n.º 2
0
def update_album(id):
    title = request.form['title']
    artist = artist_repository.select(request.form['artist_id'])
    genre = genre_repository.select(request.form['genre_id'])
    price = float(request.form['price'])
    cost_price = float(request.form['cost-price'])
    release_year = request.form['release-year']
    cover_art = request.form['cover-art']
    stock = int(request.form['stock'])
    label = label_repository.select(request.form['label_id'])
    sales_count = int(request.form['sales_count'])
    album = Album(title, artist, genre, price, cost_price, release_year,
                  cover_art, stock, label, sales_count, id)
    album_repository.update(album)
    return render_template("/albums/updated.html", **locals())
Ejemplo n.º 3
0
artist1 = Artist("ABBA")
artist_repository.save(artist1)
artist2 = Artist("Fleetwood Mac")
artist_repository.save(artist2)

album1 = Album("Greatest Hits", "Pop", artist1)
album_repository.save(album1)
album2 = Album("Rumours", "Classic Rock", artist2)
album_repository.save(album2)
album3 = Album("Voulez-Vous", "Pop", artist1)
album_repository.save(album3)

artists = artist_repository.select_all()

album1.title = "Greatest Hits Vol. 2"
album_repository.update(album1)

found_album = album_repository.select(album2.id)
print(found_album.artist.__dict__)

found_albums = artist_repository.albums(artist1)
for album in found_albums:
    print(album.__dict__)

album_repository.delete(album3.id)

albums = album_repository.select_all()
for album in albums:
    print(album.__dict__)