def raceinfo_page(): racs = Raceinfos(app.config['dsn']) method = Func(app.config['dsn']) tr_list = method.get_tracks() nat_list = method.get_nations() yr_list = method.get_years() dr_list = method.get_drivers() if request.method == 'GET': now = datetime.datetime.now() racinflist = racs.get_raceinfolist() return render_template('raceinfos.html', RaceList = racinflist, current_time = now.ctime(), TrackList = tr_list, NationList = nat_list, YearList = yr_list, DriverList = dr_list) elif 'raceinfos_to_delete' in request.form: raceinfos = request.form.getlist('raceinfos_to_delete') for raceinfo in raceinfos: racs.delete_raceinfo(raceinfo) return redirect(url_for('raceinfo_page')) elif 'raceinfos_to_add' in request.form: racs.add_raceinfo(request.form) return redirect(url_for('raceinfo_page')) elif 'raceinfos_to_update' in request.form: racs.update_raceinfo(request.form) return redirect(url_for('raceinfo_page')) elif 'raceinfos_to_searchwinner' in request.form: now = datetime.datetime.now() racinflist = racs.search_raceinfolist('winner', request.form) return render_template('raceinfos.html', RaceList = racinflist, current_time = now.ctime(), TrackList = tr_list, NationList = nat_list, YearList = yr_list, DriverList = dr_list) elif 'raceinfos_to_searchtrack' in request.form: now = datetime.datetime.now() racinflist = racs.search_raceinfolist('track', request.form) return render_template('raceinfos.html', RaceList = racinflist, current_time = now.ctime(), TrackList = tr_list, NationList = nat_list, YearList = yr_list, DriverList = dr_list)
def a_year_page(year_title): now = datetime.datetime.now() fn = Func(app.config['dsn']) rc = Raceinfos(app.config['dsn']) year_id = fn.get_id("years", year_title) if year_id is None: return render_template('404.html', current_time = now.ctime()) rclist = rc.get_raceinfolist(year_title = year_title) return render_template('a_year.html', YearTitle = year_title, RaceList = rclist, current_time = now.ctime())
def a_nation_page(nat_title): now = datetime.datetime.now() fn = Func(app.config['dsn']) nt = Nations(app.config['dsn']) rc = Raceinfos(app.config['dsn']) nat_id = fn.get_id("nations", nat_title) #will be null if unknown title entered nat = nt.get_a_nation(nat_id) if nat is None: return render_template('404.html', current_time = now.ctime()) rclist = rc.get_raceinfolist(nat_id = nat_id) trlist = nt.get_trackfornation(nat_id) return render_template('a_nation.html', Nation = nat, RaceList = rclist, TrackInfoList = trlist, current_time = now.ctime())