Пример #1
0
                "<th></th><th>Player</th><th>Opp. ranks</th><th>Avg. opp. rank</th>"
            )
            cgicommon.writeln("</tr>")

            for row in td_standings:
                (player, opp_rank_list, avg_opp_rank) = row[0:3]
                if prev_avg_opp_rank is None or prev_avg_opp_rank != avg_opp_rank:
                    pos += joint
                    joint = 1
                else:
                    joint += 1
                cgicommon.writeln("<tr class=\"miscrankrow\">")
                cgicommon.writeln("<td class=\"miscrankpos\">%d</td>" % (pos))
                cgicommon.writeln(
                    "<td class=\"miscrankname\">%s</td>" %
                    (cgicommon.player_to_link(player, tourney_name)))
                cgicommon.writeln("<td class=\"miscranklist\">%s</td>" %
                                  (", ".join([str(x) for x in opp_rank_list])))
                cgicommon.writeln(
                    "<td class=\"miscranknumbersorted\">%.2f</td>" %
                    (avg_opp_rank))
                cgicommon.writeln("</tr>")

                prev_avg_opp_rank = avg_opp_rank
            cgicommon.writeln("</table>")

    cgicommon.writeln(
        "<p>Only games which count towards the standings are considered.</p>")
    cgicommon.writeln("</div>")  # mainpane
except countdowntourney.TourneyException as e:
    cgicommon.show_tourney_exception(e)
Пример #2
0
 cgicommon.writeln("<table class=\"divtable\">")
 cgicommon.writeln("<tr>")
 cgicommon.writeln("<th rowspan=\"2\">Name</th>")
 cgicommon.writeln("<th rowspan=\"2\">Rating</th>")
 cgicommon.writeln("<th colspan=\"2\">Position</th>")
 cgicommon.writeln(
     "<th rowspan=\"2\">Promote to top division</th>")
 cgicommon.writeln("</tr>")
 cgicommon.writeln("<tr>")
 cgicommon.writeln("<th>Division</th><th>Overall</th>")
 cgicommon.writeln("</tr>")
 for p in div_players[div_index]:
     cgicommon.writeln("<tr>")
     cgicommon.writeln(
         "<td class=\"divtablename divtable\">%s%s</td>" %
         (cgicommon.player_to_link(p, tourney.get_name()),
          " (withdrawn)" if p.is_withdrawn() else ""))
     cgicommon.writeln(
         "<td class=\"divtablerating divtable\">%g</td>" %
         (p.get_rating()))
     cgicommon.writeln(
         "<td class=\"divtabledivpos divtable\">%d</td>" %
         (name_to_div_position[p.get_name()]))
     cgicommon.writeln(
         "<td class=\"divtablepos divtable\">%d</td>" %
         (name_to_position[p.get_name()]))
     cgicommon.writeln(
         "<td class=\"divtablepromote divtable\"><input type=\"checkbox\" name=\"promote%d\" value=\"1\" %s />"
         % (player_seq,
            "checked" if p.is_division_fixed() else ""))
     cgicommon.writeln(
Пример #3
0
                                    g.round_no, g.seq
                                )] = "%s %d%s - %d%s %s" % (
                                    player_names[0], parsed_score[0], "*" if
                                    (parsed_score[0] > parsed_score[1]
                                     and parsed_score[2]) else "",
                                    parsed_score[1], "*" if
                                    (parsed_score[1] >= parsed_score[0] and
                                     parsed_score[2]) else "", player_names[1])

                cgicommon.show_games_as_html_table(
                    div_games,
                    editable=False,
                    remarks=remarks,
                    include_round_column=False,
                    round_namer=None,
                    player_to_link=lambda x: cgicommon.player_to_link(
                        x, tourney.get_name(), False, True),
                    remarks_heading="Your submission")
            else:
                cgicommon.show_games_as_html_table(
                    div_games,
                    editable=True,
                    remarks=remarks,
                    include_round_column=False,
                    round_namer=None,
                    player_to_link=lambda x: cgicommon.player_to_link(
                        x, tourney.get_name(), False, True))

        if not conflict_resolution:
            cgicommon.writeln(
                "<p><input type=\"submit\" name=\"save\" value=\"Save\" onclick=\"unset_unsaved_data_warning();\" /></p>"
            )
Пример #4
0
                pos = 0
                joint = 1
                prev_overachievement = None
                for row in overachievements:
                    player = row[0]
                    seed = row[1]
                    standings_pos = row[2]
                    overachievement = row[3]
                    if prev_overachievement is None or prev_overachievement != overachievement:
                        pos += joint
                        joint = 1
                    else:
                        joint += 1
                    cgicommon.writeln("<tr>")
                    cgicommon.writeln("<td class=\"overachieverspos\">%d</td>" % (pos))
                    cgicommon.writeln("<td class=\"overachieversname\">%s</td>" % (cgicommon.player_to_link(player, tourney_name)))
                    cgicommon.writeln("<td class=\"overachieversseed\">%d</td>" % (seed))
                    cgicommon.writeln("<td class=\"overachieversstandingspos\">%d</td>" % (standings_pos))
                    cgicommon.writeln("<td class=\"overachieversoverachievement\">")
                    if overachievement == 0:
                        cgicommon.writeln("0")
                    else:
                        cgicommon.writeln("%+d" % (overachievement))
                    cgicommon.writeln("</td>")

                    cgicommon.writeln("</tr>")
                    prev_overachievement = overachievement
                cgicommon.writeln("</table>")
        if do_show_rerate_button:
            show_rerate_button(tourney)
Пример #5
0
        cgicommon.writeln("<table class=\"miscranktable\">")
        cgicommon.writeln("<tr>")
        cgicommon.writeln("<th></th><th>Player</th><th>Margins</th><th>Tuff Luck</th>")
        cgicommon.writeln("</tr>")
        for row in players_tuff_luck:
            player = row[0]
            tuffness = row[1]
            margins = row[2]
            if prev_tuffness is None or prev_tuffness != tuffness:
                pos += joint
                joint = 1
            else:
                joint += 1
            cgicommon.writeln("<tr class=\"tuffluckrow\">")
            cgicommon.writeln("<td class=\"tuffluckpos\">%d</td>" % (pos))
            cgicommon.writeln("<td class=\"tuffluckname\">%s</td>" % (cgicommon.player_to_link(player, tourney_name)))
            cgicommon.writeln("<td class=\"tuffluckmargins\">%s</td>" % (", ".join(map(str, margins))))
            cgicommon.writeln("<td class=\"tufflucktuffness\">%d</td>" % (tuffness))
            cgicommon.writeln("</tr>")
            prev_tuffness = tuffness
        cgicommon.writeln("</table>")
    cgicommon.writeln("<p>")
    cgicommon.writeln("For the purpose of Tuff Luck, games which go to a tiebreak have a margin of zero. Games adjudicated as a loss for both players do not count. Only games which count towards the standings are considered.")
    cgicommon.writeln("</p>")
    cgicommon.writeln("</div>") #mainpane
except countdowntourney.TourneyException as e:
    cgicommon.show_tourney_exception(e)

cgicommon.writeln("</body>")
cgicommon.writeln("</html>")
Пример #6
0
                '<input type="submit" class="bigbutton destroybutton" name="delroundsubmit" value="Yes, I\'m sure. Delete the round and all its games." />'
            )
            cgicommon.writeln('</p>')
            cgicommon.writeln('</form>')
            cgicommon.writeln(
                '<form action="/cgi-bin/tourneysetup.py" method="post">')
            cgicommon.writeln(
                '<input type="hidden" name="tourney" value="%s" />' %
                cgicommon.escape(tourneyname))
            cgicommon.writeln(
                '<input type="submit" class="bigbutton chickenoutbutton" name="arrghgetmeoutofhere" value="No. Cancel this and take me back to the tourney setup page." />'
            )
            cgicommon.writeln('</form>')

            num_divisions = tourney.get_num_divisions()
            cgicommon.writeln("<h2>%s</h2>" % (round_name))
            for div_index in range(num_divisions):
                cgicommon.writeln(
                    "<h3>%s</h3>" %
                    cgicommon.escape(tourney.get_division_name(div_index)))
                games = tourney.get_games(round_no=latest_round_no,
                                          division=div_index)
                cgicommon.show_games_as_html_table(
                    games, False, None, False, None,
                    lambda x: cgicommon.player_to_link(x, tourneyname))

cgicommon.writeln("</div>")

cgicommon.writeln("</body>")
cgicommon.writeln("</html>")
Пример #7
0
 def player_to_link(p):
     return cgicommon.player_to_link(p, tourneyname, p == player)
Пример #8
0
    cgicommon.writeln("<span style=\"font-weight: bold; float: left;\">")
    if num_divisions == 1:
        cgicommon.writeln(cgicommon.escape(tourney.get_name()))
    else:
        cgicommon.writeln(cgicommon.escape(tourney.get_division_name(div)))
    cgicommon.writeln("</span>")
    cgicommon.writeln("<span style=\"color: gray; float: right;\" title=\"Number of active players in %s\">%d</span>" % ("the tournament" if num_divisions == 1 else "this division", num_active_players))
    cgicommon.writeln("</td></tr>")

    for p in div_players:
        player_selected = (player and player.get_name() == p.get_name())
    
        cgicommon.writeln("<tr class=\"playerlistrow %s\">" % ("playerlistrowselected" if player_selected else ""));

        cgicommon.writeln("<td class=\"playerlistname\">");
        cgicommon.writeln(cgicommon.player_to_link(p, tourney.get_name(), emboldenise=player_selected, withdrawn=p.is_withdrawn()))
        cgicommon.writeln("</td>")

        cgicommon.writeln("<td class=\"playerlistflags\">")
        if p.get_rating() == 0:
            cgicommon.write("&nbsp;<span title=\"Prune\">&#9898;</span>")
        if p.is_avoiding_prune():
            cgicommon.write("&nbsp;<span title=\"Swiss fixture generator will behave as if this player has already played a Prune\">&#9899;</span>")
        if p.is_requiring_accessible_table():
            cgicommon.write("&nbsp;<span title=\"Requires accessible table\">&#9855;</span>");
        pref_table = p.get_preferred_table()
        if pref_table is not None:
            cgicommon.write("&nbsp;<span title=\"Prefers table %d\" class=\"playerlisttablepreficon\">%d</span>" % (pref_table, pref_table))
        cgicommon.writeln("</td>")
        cgicommon.writeln("</tr>")
cgicommon.writeln("</table>")
Пример #9
0
def show_fixtures_to_accept(tourney, generator_name, fixtures,
                            fixgen_settings):
    tourney_name = tourney.get_name()
    cgicommon.writeln(
        "<form method=\"POST\" action=\"/cgi-bin/fixturegen.py\">")
    cgicommon.writeln("<div class=\"fixtureacceptbox\">")
    cgicommon.writeln(
        "<p>I've generated the following fixtures. They won't be saved until you click the <em>Accept Fixtures</em> button.</p>"
    )
    cgicommon.writeln(
        "<input type=\"submit\" name=\"accept\" class=\"bigbutton\" value=\"Accept Fixtures\" />"
    )
    cgicommon.writeln(
        "<a href=\"/cgi-bin/fixturegen.py?tourney=%s&generator=%s\" class=\"fixturecancellink\">Discard and return to fixture generator</a>"
        % (urllib.parse.quote_plus(tourney_name),
           urllib.parse.quote_plus(generator_name)))
    cgicommon.writeln("</div>")
    num_divisions = tourney.get_num_divisions()
    for r in generated_groups.get_rounds():
        round_no = r.get_round_no()
        cgicommon.writeln("<h2>%s</h2>" % cgicommon.escape(r.get_round_name()))

        for div_index in range(num_divisions):
            round_fixtures = [
                x for x in fixtures
                if x.round_no == round_no and x.division == div_index
            ]
            if len(round_fixtures) == 0:
                continue

            standings = tourney.get_standings(division=div_index)
            standings_dict = dict()
            for s in standings:
                standings_dict[s.name] = s
            if num_divisions > 1:
                cgicommon.writeln(
                    "<h3>%s</h3>" %
                    (cgicommon.escape(tourney.get_division_name(div_index))))
            cgicommon.writeln("<table class=\"fixturetable\">")
            cgicommon.writeln(
                "<tr><th>Table</th><th>Type</th><th></th><th></th><th></th><th></th></tr>"
            )

            fixnum = 0
            last_table_no = None
            for f in round_fixtures:
                if last_table_no is None or last_table_no != f.table_no:
                    num_games_on_table = len([
                        x for x in round_fixtures if x.table_no == f.table_no
                    ])
                    first_game_on_table = True
                    cgicommon.writeln("<tr class=\"firstgameintable\">")
                else:
                    first_game_on_table = False
                    cgicommon.writeln("<tr>")

                if first_game_on_table:
                    cgicommon.writeln(
                        "<td class=\"tableno\" rowspan=\"%d\">%d</td>" %
                        (num_games_on_table, f.table_no))

                cgicommon.writeln("<td class=\"gametype\">%s</td>" %
                                  cgicommon.escape(f.game_type))
                player_td_html = []
                for player in [f.p1, f.p2]:
                    name = player.name
                    standings_row = standings_dict.get(name, None)
                    if standings_row is None:
                        player_td_html.append(
                            cgicommon.player_to_link(player,
                                                     tourney_name,
                                                     emboldenise=True,
                                                     disable_tab_order=False,
                                                     open_in_new_window=True) +
                            " ?")
                    else:
                        player_td_html.append(
                            cgicommon.player_to_link(player,
                                                     tourney_name,
                                                     emboldenise=True,
                                                     disable_tab_order=False,
                                                     open_in_new_window=True) +
                            " (%s, %d win%s%s)" %
                            (cgicommon.ordinal_number(standings_row.position),
                             standings_row.wins,
                             "" if standings_row.wins == 1 else "s", ""
                             if standings_row.draws == 0 else ", %d draw%s" %
                             (standings_row.draws,
                              "" if standings_row.draws == 1 else "s")))

                cgicommon.writeln(
                    "<td class=\"gameplayer1\">%s</td><td class=\"gamescore\">v</td><td class=\"gameplayer2\">%s</td>"
                    % tuple(player_td_html))
                num_repeats = tourney.count_games_between(f.p1, f.p2)
                if num_repeats:
                    cgicommon.writeln(
                        "<td class=\"gamerepeats\">%s repeat</td>" %
                        (cgicommon.ordinal_number(num_repeats)))
                else:
                    cgicommon.writeln("<td class=\"gameremarks\"></td>")
                cgicommon.writeln("</tr>")
                fixnum += 1
                last_table_no = f.table_no

            cgicommon.writeln("</table>")
    cgicommon.writeln(
        "<input type=\"hidden\" name=\"tourney\" value=\"%s\" />" %
        cgicommon.escape(tourney_name, True))
    cgicommon.writeln(
        "<input type=\"hidden\" name=\"generator\" value=\"%s\" />" %
        cgicommon.escape(generator_name, True))

    # Remember all the _div* settings, or check_ready might
    # object when we do try to submit the fixtures
    for name in fixgen_settings:
        if name[0:4] == "_div":
            cgicommon.writeln(
                "<input type=\"hidden\" name=\"%s\" value=\"%s\" />" %
                (cgicommon.escape(name, True),
                 cgicommon.escape(fixgen_settings[name], True)))

    fixture_plan = {
        "fixtures": [x.make_dict() for x in fixtures],
        "rounds": [{
            "round": x.get_round_no(),
            "name": x.get_round_name()
        } for x in generated_groups.get_rounds()]
    }
    json_fixture_plan = json.dumps(fixture_plan)
    cgicommon.writeln(
        "<input type=\"hidden\" name=\"jsonfixtureplan\" value=\"%s\" />" %
        cgicommon.escape(json_fixture_plan, True))
    cgicommon.writeln("<div class=\"fixtureacceptbox\">")
    cgicommon.writeln(
        "<input type=\"submit\" name=\"accept\" value=\"Accept Fixtures\" class=\"bigbutton\" />"
    )
    cgicommon.writeln(
        "<a href=\"/cgi-bin/fixturegen.py?tourney=%s&generator=%s\" class=\"fixturecancellink\">Discard and return to fixture generator</a>"
        % (urllib.parse.quote_plus(tourney_name),
           urllib.parse.quote_plus(generator_name)))
    cgicommon.writeln("</div>")
    cgicommon.writeln("</form>")