Example #1
0
def performances_generate_listing(request):
    group = get_object_or_404(Group, pk=request.POST['group_id'])
    teams = list(group.teams.all())

    n_rounds = 3
    if group.results_type == 'D':
        n_rounds = 2

    for rnd in range(1, 1+n_rounds):
        for team in teams:
            performance = Performance(team=team, round_number=rnd, referee=request.user)
            performance.save()
            group.performances.add(performance)
       
    group.save()
    performances = group.performances.all().order_by('round_number')
    return {'performances': performances, 'group': group}
Example #2
0
def table_final_generate(request, group_id):
    group = get_object_or_404(Group, pk=group_id)
    for team in group.teams.all():
        teamres = group.performances.filter(team=team).order_by('points', '-time').reverse()   
        newperf = Performance(team=team, round_number=4)
        if group.results_type == 'S':
            newperf.referee = request.user
            newperf.floating_victim = teamres[0].floating_victim + teamres[1].floating_victim
            newperf.linear_victim = teamres[0].linear_victim + teamres[1].linear_victim
            newperf.kit_deploy = teamres[0].kit_deploy + teamres[1].kit_deploy
            newperf.bump = teamres[0].bump + teamres[1].bump
            newperf.ramp_up = teamres[0].ramp_up + teamres[1].ramp_up
            newperf.ramp_down = teamres[0].ramp_down + teamres[1].ramp_down
            newperf.checkpoints = teamres[0].checkpoints + teamres[1].checkpoints
            newperf.successful_exit = teamres[0].successful_exit + teamres[1].successful_exit
            newperf.lack_of_progress = teamres[0].lack_of_progress + teamres[1].lack_of_progress
            newperf.reliability = teamres[0].reliability + teamres[1].reliability

            newperf.points = teamres[0].points + teamres[1].points
            newperf.time = teamres[0].time + teamres[1].time

        else:
            newperf = teamres[0]
        
        newperf.save()
        group.perfs_final.add(newperf)

    group.result_table_generated = True
    group.save()
    return redirect('rescueB.views.group', group_id)