Пример #1
0
def edit_artist(artist_id):
    form = ArtistForm()
    current_artist = db.session.query(Artist).get(artist_id)
    artist = Artist.info(current_artist)
    form.name.data = artist["name"]
    form.genres.data = artist["genres"]
    form.city.data = artist["city"]
    form.state.data = artist["state"]
    form.phone.data = artist["phone"]
    form.facebook_link.data = artist["facebook_link"]
    # TODO: populate form with fields from artist with ID <artist_id>
    return render_template('forms/edit_artist.html', form=form, artist=artist)
Пример #2
0
def edit_artist(artist_id):
    form = ArtistForm()
    artist_data = Artist.query.get(artist_id)
    if artist_data:
        artist_details = Artist.info(artist_data)
        form.name.data = artist_details["name"]
        form.genres.data = artist_details["genres"]
        form.city.data = artist_details["city"]
        form.state.data = artist_details["state"]
        form.phone.data = artist_details["phone"]
        form.website.data = artist_details["website"]
        form.facebook_link.data = artist_details["facebook_link"]
        form.seeking_venue.data = artist_details["seeking_venue"]
        form.seeking_description.data = artist_details["seeking_description"]
        form.image_link.data = artist_details["image_link"]
        return render_template('forms/edit_artist.html',
                               form=form,
                               artist=artist_details)
    return render_template('errors/404.html')
Пример #3
0
def show_artist(artist_id):
    # shows the venue page with the given venue_id
    # TODO: replace with real venue data from the venues table, using venue_id
    current_artist = db.session.query(Artist).get(artist_id)
    data = Artist.info(current_artist)
    current_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
    new_shows = db.session.query(Show).options(db.joinedload(
        Show.Artist)).filter(Show.artist_id == artist_id).filter(
            Show.start_time > current_time).all()
    new_shows_list = list(map(Show.venue_info, new_shows))
    data["upcoming_shows"] = new_shows_list
    data["upcoming_shows_count"] = len(new_shows_list)
    past_shows = db.session.query(Show).options(db.joinedload(
        Show.Artist)).filter(Show.artist_id == artist_id).filter(
            Show.start_time <= current_time).all()
    past_shows_list = list(map(Show.venue_info, past_shows))
    data["past_shows"] = past_shows_list
    data["past_shows_count"] = len(past_shows_list)

    return render_template('pages/show_artist.html', artist=data)