def show_artist(artist_id): artist_query = Artist.query.get(artist_id) if artist_query: artist_details = Artist.details(artist_query) current_time = datetime.now().strftime('%Y-%m-%d') upcoming_shows_query = Show.query.options( db.joinedload('Artist')).filter( Show.artist_id == artist_id).filter( Show.start_time >= current_time).all() for query in upcoming_shows_query: print(query.id) print(query.artist_id) print(query.venue_id) print(query.start_time) upcoming_shows_list = list( map(Show.details_venue, upcoming_shows_query)) artist_details["upcoming_shows"] = upcoming_shows_list artist_details["upcoming_shows_count"] = len(upcoming_shows_list) past_shows_query = Show.query.options(db.joinedload('Artist')).filter( Show.artist_id == artist_id).filter( Show.start_time <= current_time).all() past_shows_list = list(map(Show.details_venue, past_shows_query)) artist_details["past_shows"] = past_shows_list artist_details["past_shows_count"] = len(past_shows_list) print(artist_details) return render_template('pages/show_artist.html', artist=artist_details) return render_template('errors/404.html')
def show_artist(artist_id): # shows the artist page with the given artist_id # TODO: replace with real Artist data from the Artist table, using artist_id artist_details = {} try: artist_query = Artist.query.get(artist_id) if artist_query: artist_details = Artist.details(artist_query) current_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S') show_query = Show.query.options(db.joinedload( Show.Artist)).filter(Show.artist_id == artist_id) upcoming_show_list = list( map(Show.artist_details(), show_query.filter(Show.date_time > current_time).all())) past_show_list = list( map(Show.artist_details(), show_query.filter(Show.date_time <= current_time).all())) artist_details["upcoming_shows"] = upcoming_show_list artist_details["upcoming_shows_count"] = len(upcoming_show_list) artist_details["past_shows"] = past_show_list artist_details["past_shows_count"] = len(past_show_list) except: db.session.rollback() finally: db.session.close() if artist_details: return render_template('pages/show_artist.html', artist=artist_details) else: return render_template('errors/404.html')
def show_artist(artist_id): """shows artist page with artist details Arguments: artist_id {int} -- artist id Returns: dictionary -- artist details """ data = Artist.query.get(artist_id) artist_data = {} current_time = datetime.now() if data: past_results = (db.session.query(Musicshows).filter( Musicshows.artist_id == artist_id).filter( Musicshows.start_time < current_time).all()) upcoming_results = (db.session.query(Musicshows).filter( Musicshows.artist_id == artist_id).filter( Musicshows.start_time > current_time).all()) artist_data = Artist.details(data) artist_data["past_shows"] = list( map(Musicshows.venue_details, past_results)) artist_data["upcoming_shows"] = list( map(Musicshows.venue_details, upcoming_results)) artist_data["past_shows_count"] = len(past_results) artist_data["upcoming_shows_count"] = len(upcoming_results) return render_template("pages/show_artist.html", artist=data)
def edit_artist(artist_id): form = ArtistForm() # TODO: populate form with fields from artist with ID <artist_id> artist_query = Artist.query.get(artist_id) if artist_query: artist_details = Artist.details(artist_query) 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.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')
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 artist_query = Artist.query.get(artist_id) if artist_query: artist_details = Artist.details(artist_query) current_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S') new_shows_query = Show.query.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_details, new_shows_query)) artist_details["upcoming_shows"] = new_shows_list artist_details["upcoming_shows_count"] = len(new_shows_list) past_shows_query = Show.query.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_details, past_shows_query)) artist_details["past_shows"] = past_shows_list artist_details["past_shows_count"] = len(past_shows_list) return render_template('pages/show_artist.html', artist=artist_details) return render_template('errors/404.html')
def edit_artist(artist_id): form = ArtistForm() data = request.form artist_query = Artist.query.get(artist_id) if artist_query: artist_details = Artist.details(artist_query) 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.facebook_link.data = artist_details["facebook_link"] return render_template('forms/edit_artist.html', form=form, artist=artist_details) return render_template('errors/404.html')
def edit_artist(artist_id): form = ArtistForm() artist_query = Artist.query.get(artist_id) if artist_query: artist_details = Artist.details(artist_query) 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)
def show_artist(artist_id): """Establish Individiual Artist Page.""" artist_query = Artist.query.get(artist_id) artist_details = Artist.details(artist_query) current_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S') new_shows_query = Show.query.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_details, new_shows_query)) artist_details["upcoming_shows"] = new_shows_list artist_details["upcoming_shows_count"] = len(new_shows_list) past_shows_query = Show.query.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_details, past_shows_query)) artist_details["past_shows"] = past_shows_list artist_details["past_shows_count"] = len(past_shows_list) return render_template('pages/show_artist.html', artist=artist_details)
def show_artist(artist_id): artist_query = Artist.query.get(artist_id) if artist_query: artist_details = Artist.details(artist_query) current_time = datetime.now() new_shows_query = Show.query.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_details, new_shows_query)) artist_details["upcoming_shows"] = new_shows_list artist_details["upcoming_shows_count"] = len(new_shows_list) past_shows_query = Show.query.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_details, past_shows_query)) artist_details["past_shows"] = past_shows_list artist_details["past_shows_count"] = len(past_shows_list) return render_template('pages/show_artist.html', artist=artist_details) return render_template('errors/404.html')