Beispiel #1
0
cgicommon.writeln("<div class=\"mainpane\">")
cgicommon.writeln("<h1>Hangover Team Setup</h1>")

if tourneyname is None:
    cgicommon.writeln("<h1>Sloblock</h1>")
    cgicommon.writeln(
        "<p>No tourney name specified. <a href=\"/cgi-bin/home.py\">Home</a></p>"
    )
elif not tourney:
    cgicommon.writeln("<p>No valid tourney name specified</p>")
else:
    num_players = len(tourney.get_players())

    if player_teams_set:
        cgicommon.show_success_box("Teams set successfully.")
    elif tourney_exception:
        cgicommon.show_tourney_exception(e)

    #print '<p>'

    teams = tourney.get_teams()
    player_teams = sorted(tourney.get_player_teams(),
                          key=lambda x: x[0].get_rating(),
                          reverse=True)

    if num_players == 0:
        cgicommon.writeln(
            "<p>This tourney doesn't have any players, so you can't specify teams yet.</p>"
        )
        cgicommon.writeln(
Beispiel #2
0
cgicommon.writeln("<body>")
cgicommon.writeln("<h1>Welcome to Atropine</h1>")

if cgicommon.is_client_from_localhost():
    # Client is from localhost, so serve the administrator's front page, which
    # produces a menu of tournaments and the ability to create a new one.
    tourney_created = False

    if request_method == "POST" and tourneyname:
        try:
            tourney = countdowntourney.tourney_create(tourneyname,
                                                      cgicommon.dbdir)
            tourney.close()
            cgicommon.show_success_box(
                "Tourney \"%s\" was created successfully." %
                cgicommon.escape(tourneyname))
            cgicommon.writeln("<p>")
            cgicommon.writeln(
                '<a href="/cgi-bin/tourneysetup.py?tourney=%s">Click here to continue</a>'
                % urllib.parse.quote_plus(tourneyname))
            cgicommon.writeln("</p>")
            tourney_created = True
        except countdowntourney.TourneyException as e:
            cgicommon.show_tourney_exception(e)

    if not tourney_created:
        # If name has been filled in, attempt to create tourney

        cgicommon.writeln("<h2>Create new tourney</h2>")
        cgicommon.writeln('<form action="%s" method="POST">' %
Beispiel #3
0
    if not username:
        username = state.get("username", "")
    if not password:
        password = state.get("password", "")
    if private_tourney is None:
        private_tourney = state.get("private", None)
        if private_tourney is None:
            private_tourney = tourney.is_broadcast_private()

    upload_on = state.get("publishing", False)

    if exception_text:
        cgicommon.show_error_text(exception_context + ": " + exception_text)
    if delete_success:
        cgicommon.show_success_box(
            "Successfully deleted tourney <strong>%s</strong> from the website."
            % (cgicommon.escape(tourney_name)))

    web_link = colive_url_base + "/" + cgicommon.escape(tourney_name, True)
    web_link_raw = colive_url_base + "/" + tourney_name
    cgicommon.writeln(
        "<p>This will upload the tourney state every few seconds so that games, scores and standings are visible at <a href=\"%s\" target=\"_blank\">%s <img src=\"/images/opensinnewwindow.png\" alt=\"Opens in new window\"/></a></p>"
        % (web_link, web_link))
    cgicommon.writeln("<p>You will need:</p>")
    cgicommon.writeln("<ul>")
    cgicommon.writeln(
        "<li>A username and password for the server at %s. If you don't have these, then ignore this whole feature. Just pretend it doesn't exist.</li>"
        % (cgicommon.escape(uploader.http_server_host)))
    cgicommon.writeln("<li>A connection to the internet.</li>")
    cgicommon.writeln("</ul>")
    cgicommon.writeln(
if tourneyname is None:
    cgicommon.writeln("<h1>Sloblock</h1>")
    cgicommon.writeln(
        "<p>No tourney name specified. <a href=\"/cgi-bin/home.py\">Home</a></p>"
    )
elif not tourney:
    cgicommon.writeln("<p>No valid tourney name specified</p>")
else:
    #print '<p><a href="%s?tourney=%s">%s</a></p>' % (baseurl, urllib.quote_plus(tourneyname), cgicommon.escape(tourneyname));
    if request_method == "POST" and "submit" in form:
        try:
            tourney.set_show_tournament_rating_column(show_tournament_rating)
            tourney.set_tournament_rating_config(tr_bonus, tr_diff_cap)
            tourney.set_rank_method(rank)
            tourney.set_rank_finals(rank_finals)
            cgicommon.show_success_box("Options updated.")
        except countdowntourney.TourneyException as e:
            cgicommon.show_tourney_exception(e)

    cgicommon.writeln(('<form action="%s?tourney=%s" method="post">' %
                       (baseurl, urllib.parse.quote_plus(tourneyname))))
    cgicommon.writeln(('<input type="hidden" name="tourney" value="%s" />' %
                       cgicommon.escape(tourneyname, True)))

    cgicommon.writeln("<h2>Team Setup</h2>")
    cgicommon.writeln("""<p>Atropine can assign each player to one of
two teams. Every match between players on opposing teams gives a point to the
winner's team. The team scores are displayed alongside the standings.</p>""")
    cgicommon.writeln("""<p>
<a href=\"/cgi-bin/teamsetup.py?tourney=%s\">Go to the Team Setup page</a>
</p>""" % (urllib.parse.quote_plus(tourneyname)))
Beispiel #5
0
    cgicommon.writeln("</body></html>")
    sys.exit(0)

try:
    tourney = countdowntourney.tourney_open(tourney_name, cgicommon.dbdir)
    cgicommon.show_sidebar(tourney, show_misc_table_links=True)


    cgicommon.writeln("<div class=\"mainpane\">")

    cgicommon.writeln("<h1>Overachievers</h1>")

    if request_method == "POST" and "reratebyplayerid" in form and "reratebyplayeridconfirm" in form:
        try:
            tourney.rerate_players_by_id()
            cgicommon.show_success_box("Players successfully rerated by player ID.")
        except countdowntourney.TourneyException as e:
            cgicommon.show_tourney_exception(e)

    if tourney.get_num_games() == 0:
        cgicommon.writeln("<p>No games have been played yet.</p>")
    else:
        cgicommon.writeln("<p>Each player is assigned a seed according to their rating, with the top-rated player in a division being the #1 seed, and so on down. Players are listed here in order of the difference between their position in the standings table and their seed position.</p>")

        num_divisions = tourney.get_num_divisions()
        do_show_rerate_button = False
        for div_index in range(num_divisions):
            div_name = tourney.get_division_name(div_index)
            overachievements = tourney.get_players_overachievements(div_index)
            if num_divisions > 1:
                cgicommon.writeln("<h2>%s</h2>" % (cgicommon.escape(div_name)))
Beispiel #6
0
                    % (row_num, row_num, row_num))
                for index in range(len(row)):
                    value = row[index]
                    if value is None:
                        value_str = "NULL"
                    else:
                        value_str = value
                    typ = result_col_types[index]
                    cgicommon.writeln(
                        "<td%s>%s</td>" %
                        (" class=\"sqlnull\"" if value is None else "",
                         cgicommon.escape(value_str)))
                cgicommon.writeln("</tr>")
                row_num += 1
            cgicommon.writeln("</table>")
        else:
            if num_rows_affected is not None and num_rows_affected >= 0:
                cgicommon.show_success_box(
                    "Query successful, %d row%s affected." %
                    (num_rows_affected, "" if num_rows_affected == 1 else "s"))
            else:
                cgicommon.show_success_box("Query successful.")

    cgicommon.writeln("</div>")

cgicommon.writeln("</div>")

cgicommon.writeln("</body></html>")

sys.exit(0)
Beispiel #7
0
                            try:
                                player_table_pref = int(field[1:])
                                if player_table_pref < 1:
                                    player_table_pref = None
                            except ValueError:
                                player_table_pref = None

                player_list.append(
                    countdowntourney.EnteredPlayer(
                        player_name, player_rating, div_index, player_team_id,
                        player_avoid_prune, player_withdrawn,
                        player_requires_accessible_table, player_table_pref))
            prev_player_name = player_name
        try:
            tourney.set_players(player_list, auto_rating_behaviour)
            cgicommon.show_success_box("Player list updated.")
        except countdowntourney.TourneyException as e:
            cgicommon.show_tourney_exception(e)

    num_divisions = tourney.get_num_divisions()

    if request_method == "POST" and rules_submit:
        try:
            # User submitted new tourney rules, so set them

            # Accessible tables
            try:
                if not accessible_tables_string:
                    accessible_tables = []
                else:
                    accessible_tables = [
Beispiel #8
0
        "<p>No tourney name specified. <a href=\"/cgi-bin/home.py\">Home</a></p>"
    )
elif not tourney:
    cgicommon.show_sidebar(None)
    cgicommon.writeln("<div class=\"mainpane\">")
    cgicommon.writeln("<h1>Delete round</h1>")
    cgicommon.writeln("<p>No valid tourney name specified</p>")
else:
    #print '<p><a href="%s?tourney=%s">%s</a></p>' % (baseurl, urllib.quote_plus(tourneyname), cgicommon.escape(tourneyname));
    if confirm:
        try:
            tourney.delete_round(round_no)
            cgicommon.show_sidebar(tourney)
            cgicommon.writeln("<div class=\"mainpane\">")
            cgicommon.writeln("<h1>Delete round</h1>")
            cgicommon.show_success_box("Round %d deleted successfully." %
                                       (round_no))
            cgicommon.writeln(
                '<p><a href="/cgi-bin/tourneysetup.py?tourney=%s">Back to tourney setup</a></p>'
                % urllib.parse.quote_plus(tourneyname))
        except countdowntourney.TourneyException as e:
            cgicommon.show_sidebar(tourney)
            cgicommon.writeln("<div class=\"mainpane\">")
            cgicommon.writeln("<h1>Delete round</h1>")
            cgicommon.show_tourney_exception(e)
    else:
        cgicommon.show_sidebar(tourney)
        cgicommon.writeln("<div class=\"mainpane\">")
        cgicommon.writeln("<h1>Delete round</h1>")
        latest_round_no = tourney.get_latest_round_no()
        if latest_round_no is None:
            cgicommon.writeln('<p>There are no rounds to delete!</p>')
Beispiel #9
0
        cgicommon.writeln(
            "<a href=\"/cgi-bin/tourneysetup.py?tourney=%s\">Set the player list at the tourney setup page</a>"
            % (urllib.parse.quote_plus(tourney_name)))
    else:
        cgicommon.writeln(
            "<a href=\"/cgi-bin/fixturegen.py?tourney=%s\">Sigh...</a>" %
            (urllib.parse.quote_plus(tourney_name)))
    cgicommon.writeln("</p>")

# Show any warning...
if warning_content:
    cgicommon.show_warning_box(warning_content)

# And a success box, if we've just saved the new fixtures to the db.
if success_content:
    cgicommon.show_success_box(success_content)

# show_fixgen_list is set when the user hasn't yet picked a fixture generator.
if show_fixgen_list:
    num_divisions = tourney.get_num_divisions()

    cgicommon.writeln("<p>")
    cgicommon.writeln(
        "When you want to generate the next round's fixtures, choose a fixture generator from the list below."
    )
    if num_divisions > 1:
        cgicommon.writeln(
            "If you want to generate fixtures for only one division or a subset of divisions, you'll be asked which divisions to generate fixtures for on the next screen."
        )

    cgicommon.writeln("</p>")