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())
def a_track_page(track_title): now = datetime.datetime.now() fn = Func(app.config['dsn']) nt = Nations(app.config['dsn']) rc = Raceinfos(app.config['dsn']) nat_id = fn.get_country(track_title) tid=fn.get_trackid(track_title) yr=fn.get_firstrace(track_title) nat_name=fn.get_countryname(nat_id) nat = nt.get_a_nation(nat_id) if nat is None: return render_template('404.html', current_time = now.ctime()) rclist = fn.get_trackinfo(tid) return render_template('a_track.html', yr=yr,rally=track_title,Nation = nat,nat_name=nat_name, RaceList = rclist, current_time = now.ctime())
def nation_page(): nats = Nations(app.config['dsn']) if request.method == 'GET': now = datetime.datetime.now() nlist = nats.get_nationlist() return render_template('nations.html', NationList = nlist, current_time = now.ctime()) elif 'nations_to_delete' in request.form: ids = request.form.getlist('nations_to_delete') for id in ids: nats.delete_nation(id) return redirect(url_for('nation_page')) elif 'nations_to_add' in request.form: nats.add_nation(request.form['title']) return redirect(url_for('nation_page')) elif 'nations_to_update' in request.form: nats.update_nation(request.form['id'], request.form['title']) return redirect(url_for('nation_page'))