def round_view_html(event_id, round_number): f3f_round = RoundDAO().get_from_ids(event_id, round_number, fetch_runs=True) page = ResultPage(title=f3f_round.event.name + '\t' + f3f_round.display_name() + '(id:' + str(f3f_round.round_number) + ')', event=f3f_round.event) best_runs = f3f_round.get_best_runs() best_runs_string = 'Best time : <br>' for run in best_runs: if run is not None: best_runs_string += run.to_string() table = ResultTable(title=best_runs_string, css_id='ranking') header = Header(name=Cell('Bib')) header.add_cell(Cell('Group')) header.add_cell(Cell('Name')) header.add_cell(Cell('Flight time')) header.add_cell(Cell('Score')) table.set_header(header) #Later loop on rounds and round groups round_group = f3f_round.groups[0] for round_group in f3f_round.groups: round_group.compute_scores() for competitor in sorted(round_group.runs): row = Line(name=Cell(str(competitor.bib_number))) row.add_cell(Cell(str(round_group.group_number))) row.add_cell(Cell(competitor.pilot.to_string())) row.add_cell(Cell(round_group.run_value_as_string(competitor))) row.add_cell(Cell(str( round_group.run_score_as_string(competitor)))) table.add_line(row) page.add_table(table) table = ResultTable(title='Remaining pilots to fly', css_id='ranking') header = Header(name=Cell('Bib')) header.add_cell(Cell('Group')) header.add_cell(Cell('Name')) table.set_header(header) for bib_number in f3f_round.get_remaining_bibs_to_fly(): row = Line(name=Cell(str(bib_number))) row.add_cell( Cell( str( f3f_round.find_group( f3f_round.event.competitors[bib_number]).group_number)) ) row.add_cell( Cell(f3f_round.event.competitors[bib_number].display_name())) table.add_line(row) page.add_table(table) result = page.to_html() return result
def manage_round(request): if not request.user.is_authenticated: return redirect('%s?next=%s' % ('sign_in', request.path)) Utils.set_port_number(request.META['SERVER_PORT']) event_id = request.GET.get('event_id') round_number = request.GET.get('round_number') f3f_round = RoundDAO().get_from_ids(event_id, round_number, fetch_runs=True) page = ResultPage(title=f3f_round.event.name + '\t' + f3f_round.display_name() + '(id:' + str(f3f_round.round_number) + ')', event=f3f_round.event) best_runs = f3f_round.get_best_runs() best_runs_string = 'Best time : <br>' for run in best_runs: if run is not None: best_runs_string += run.to_string() table = ResultTable(title=best_runs_string, css_id='ranking') header = Header(name=Cell('Bib')) header.add_cell(Cell('Group')) header.add_cell(Cell('Name')) header.add_cell(Cell('Flight time')) header.add_cell(Cell('Score')) header.add_cell(Cell('Penalty')) header.add_cell(Cell('')) header.add_cell(Cell('')) header.add_cell(Cell('')) header.add_cell(Cell('')) header.add_cell(Cell('')) table.set_header(header) # Later loop on rounds and round groups for round_group in f3f_round.groups: round_group.compute_scores() for competitor in sorted(round_group.runs): row = Line(name=Cell(str(competitor.bib_number))) row.add_cell(Cell(str(round_group.group_number))) row.add_cell(Cell(competitor.pilot.to_string())) row.add_cell(Cell(round_group.run_value_as_string(competitor))) row.add_cell(Cell(str( round_group.run_score_as_string(competitor)))) row.add_cell(Cell(str(round_group.get_penalty(competitor)))) row.add_cell( Link( 'Refly', 'give_refly?event_id=' + str(event_id) + '&round_number=' + str(round_number) + '&bib_number=' + str(competitor.bib_number))) row.add_cell( Link( 'Give 0', 'give_zero?event_id=' + str(event_id) + '&round_number=' + str(round_number) + '&bib_number=' + str(competitor.bib_number))) row.add_cell( Link( 'Give 100 penalty', 'give_penalty?event_id=' + str(event_id) + '&round_number=' + str(round_number) + '&bib_number=' + str(competitor.bib_number) + '&penalty=100')) row.add_cell( Link( 'Give 1000 penalty', 'give_penalty?event_id=' + str(event_id) + '&round_number=' + str(round_number) + '&bib_number=' + str(competitor.bib_number) + '&penalty=1000')) row.add_cell( Link( 'Cancel penalty', 'give_penalty?event_id=' + str(event_id) + '&round_number=' + str(round_number) + '&bib_number=' + str(competitor.bib_number) + '&penalty=0')) table.add_line(row) page.add_table(table) table = ResultTable(title='Flight order', css_id='ranking') header = Header(name=Cell('Bib')) header.add_cell(Cell('Group')) header.add_cell(Cell('Name')) header.add_cell(Cell('')) table.set_header(header) for group in f3f_round.groups: for bib_number in group.get_flight_order(): row = Line(name=Cell(str(bib_number))) row.add_cell(Cell(str(group.group_number))) row.add_cell( Cell(f3f_round.event.competitors[bib_number].display_name())) row.add_cell( Link( 'Set time', 'set_time?event_id=' + str(event_id) + '&round_number=' + str(round_number) + '&bib_number=' + str(bib_number))) table.add_line(row) page.add_table(table) result = page.to_html() return HttpResponse(result)