Пример #1
0
def scout_event():
    event_id = session['event_id']
    session['match_form_counter']=0
    event = models.Event.query.filter_by(id=event_id).first()
    matches = models.Match.query.filter_by(event_id = event_id)
    t = tba()
    teams = t.get_event_teams(event.get_key())
    team1 = teams[:len(teams)/2]
    team2 = teams[len(teams)/2:]
    return render_template('scout_event.html', event=event, team1=team1, team2=team2, matches=matches)
Пример #2
0
def scout_match():
    event_id = session['event_id']
    t = tba()
    match_event = models.Event.query.filter_by(id=event_id).first()
    teams =[]
    tba_teams = t.get_event_teams(match_event.get_key())
    for i in tba_teams:
        team = (str(i['team_number']), str(i['team_number']))
        teams.append(team)

    form = ScoutMatch()
    form.team_number.choices=teams

    if request.method == 'POST':
        if form.validate_on_submit():
            if session['match_form_counter'] < 6:
               session['match_form_counter']=session['match_form_counter']+1
               match_number = form.match_number.data
               team_number = form.team_number.data
               team = models.Team.query.filter_by(number=team_number).first()
               #Low Bar
               lb_total_attempts = int(form.lb_total_attempts.data)
               lb_success_attempts = int(form.lb_success_attempts.data)
               #Rock Wall
               rw_total_attempts = int(form.rw_total_attempts.data)
               rw_success_attempts = int(form.rw_success_attempts.data)
               #Rough Terrain
               rt_total_attempts = int(form.rt_total_attempts.data)
               rt_success_attempts = int(form.rt_success_attempts.data)
               #Moat
               moat_total_attempts = int(form.moat_total_attempts.data)
               moat_success_attempts = int(form.moat_success_attempts.data)
               #Rampart
               rampart_total_attempts = int(form.rampart_total_attempts.data)
               rampart_success_attempts = int(form.rampart_success_attempts.data)
               #Cheval de Frise
               cdf_total_attempts = int(form.cdf_total_attempts.data)
               cdf_success_attempts = int(form.cdf_success_attempts.data)
               #Portcullis
               port_total_attempts = int(form.port_total_attempts.data)
               port_success_attempts = int(form.port_success_attempts.data)
               #Sallyport
               sally_total_attempts = int(form.sally_total_attempts.data)
               sally_success_attempts = int(form.sally_success_attempts.data)
               #Drawbridge
               db_total_attempts = int(form.db_total_attempts.data)
               db_success_attempts = int(form.db_success_attempts.data)
               #High Goal
               hg_total_attempts = int(form.hg_total_attempts.data)
               hg_success_attempts = int(form.hg_success_attempts.data)
               #Low Goal
               lg_total_attempts = int(form.lg_total_attempts.data)
               lg_success_attempts = int(form.lg_success_attempts.data)
               #Hanging
               hang_total_attempts = int(form.hang_total_attempts.data)
               hang_success_attempts = int(form.hang_success_attempts.data)
               #Challenging
               ch_total_attempts = int(form.ch_total_attempts.data)
               ch_success_attempts = int(form.ch_success_attempts.data)
               match = models.Match(match_number, team_number, lb_total_attempts,
                 lb_success_attempts, rw_total_attempts, rw_success_attempts,
                 rt_total_attempts, rt_success_attempts, moat_total_attempts,
                 moat_success_attempts, rampart_total_attempts, rampart_success_attempts,
                 cdf_total_attempts, cdf_success_attempts, port_total_attempts,
                 port_success_attempts, sally_total_attempts, sally_success_attempts,
                 db_total_attempts, db_success_attempts, hg_total_attempts, hg_success_attempts,
                 lg_total_attempts, lg_success_attempts, hang_total_attempts, hang_success_attempts,
                 ch_total_attempts, ch_success_attempts, match_event, team)
               db.session.add(match)
               db.session.commit()
               flash('A New Match Created: %s' % (match_number), 'success')

               return redirect(url_for('scout_match'))
            else:
                session['match_form_counter']=0
                return redirect(url_for('scout_event'))

        else:
            session['match_form_counter']=0
            error = form.errors
            flash(error, 'danger')
            return redirect(url_for('scout_event'))

    return render_template('scout_match.html', form=form, counter=session['match_form_counter'])