def include_scripts(dir_name, url_path): for filename in sorted(os.listdir(dir_name)): if (os.path.isdir(dir_name + "/" + filename)): include_scripts(dir_name + "/" + filename, url_path + "/" + filename) elif filename[-3:] == ".js": base_filename = os.path.basename(filename) cgicommon.writeln( "<script src=\"%s/%s\"></script>" % (cgicommon.escape( url_path, True), cgicommon.escape(base_filename, True)))
def show_player_drop_down_box(players, control_name): cgicommon.writeln("<select name=\"%s\">" % (control_name)) cgicommon.writeln("<option value=\"\">-- select player --</option>") for p in players: cgicommon.writeln( "<option value=\"%s\">%s (%g)</option>" % (cgicommon.escape( p.name, True), cgicommon.escape(p.name), p.rating)) cgicommon.writeln("</select>")
def fatal_exception(exc, tourney=None): cgicommon.print_html_head("Player View") cgicommon.writeln("<body>") if tourney: cgicommon.show_sidebar(tourney) cgicommon.writeln("<div class=\"mainpane\">") cgicommon.show_tourney_exception(exc) cgicommon.writeln("</div>") cgicommon.writeln("</body></html>") sys.exit(1)
def fatal_exception(exc, tourney=None): cgicommon.print_html_head("Table Index") cgicommon.writeln("<body>") if tourney: cgicommon.show_sidebar(tourney, show_misc_table_links=True) cgicommon.writeln("<div class=\"mainpane\">") cgicommon.show_tourney_exception(exc) cgicommon.writeln("</div>") cgicommon.writeln("</body></html>") sys.exit(1)
def show_division_drop_down_box(control_name, tourney, player): num_divisions = tourney.get_num_divisions() cgicommon.writeln("<select name=\"%s\">" % (cgicommon.escape(control_name, True))) for div in range(num_divisions): cgicommon.writeln("<option value=\"%d\" %s >%s (%d active players)</option>" % (div, "selected" if (player is not None and div == player.get_division()) or (player is None and div == 0) else "", cgicommon.escape(tourney.get_division_name(div)), tourney.get_num_active_players(div))) cgicommon.writeln("</select>")
def show_player_selection(players, control_name, value): cgicommon.writeln("<select name=\"%s\">" % cgicommon.escape(control_name, True)) for p in players: player_name = p.get_name() if player_name == value: sel = " selected" else: sel = "" cgicommon.writeln( "<option value=\"%s\"%s>%s</option>" % (cgicommon.escape( player_name, True), sel, cgicommon.escape(player_name))) cgicommon.writeln("</select>")
def float_or_none(s): if s is None: return None try: return float(s) except ValueError: return None cgitb.enable() cgicommon.set_module_path() import countdowntourney cgicommon.writeln("Content-Type: text/html; charset=utf-8") cgicommon.writeln("") baseurl = "/cgi-bin/tourneysetupadvanced.py" form = cgi.FieldStorage() tourneyname = form.getfirst("tourney") show_tournament_rating = bool( int_or_none(form.getfirst("showtournamentratingcolumn"))) tr_bonus = float_or_none(form.getfirst("tournamentratingbonus")) tr_diff_cap = float_or_none(form.getfirst("tournamentratingdiffcap")) rank = int_or_none(form.getfirst("rank")) rank_finals = int_or_none(form.getfirst("rankfinals")) tourney = None request_method = os.environ.get("REQUEST_METHOD", "")
import countdowntourney import uploadercli import uploader colive_url_base = "https://%s%s/co" % (uploader.http_server_host, (":" + str(uploader.http_server_port) if uploader.http_server_port else "")) def unix_time_to_str(unix_time): if unix_time is None: return None return time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(unix_time)) cgicommon.writeln("Content-Type: text/html; charset=utf-8") cgicommon.writeln("") form = cgi.FieldStorage() tourney_name = form.getfirst("tourney") cgicommon.print_html_head("Live Broadcast Setup: %s" % (tourney_name)) cgicommon.writeln("<body>") cgicommon.assert_client_from_localhost() tourney = None if tourney_name is not None: try: tourney = countdowntourney.tourney_open(tourney_name, cgicommon.dbdir)
#!/usr/bin/python3 import sys import cgicommon import urllib.request, urllib.parse, urllib.error import cgi import cgitb baseurl = "/cgi-bin/timdownaward.py" cgitb.enable() cgicommon.writeln("Content-Type: text/html; charset=utf-8") cgicommon.writeln("") form = cgi.FieldStorage() tourney_name = form.getfirst("tourney") tourney = None cgicommon.set_module_path() import countdowntourney cgicommon.print_html_head("Tim Down Award: %s" % (tourney_name)) cgicommon.writeln("<body>") cgicommon.assert_client_from_localhost() if tourney_name is None:
#!/usr/bin/python3 import sys import os import cgicommon import urllib.request, urllib.parse, urllib.error import cgi import cgitb cgitb.enable() cgicommon.writeln("Content-Type: text/html; charset=utf-8") cgicommon.writeln("") form = cgi.FieldStorage() tourney_name = form.getfirst("tourney") baseurl = "/cgi-bin/overachievers.py" tourney = None cgicommon.set_module_path() import countdowntourney def show_rerate_button(tourney): tourney_name = tourney.get_name() cgicommon.writeln("<h2>Rerate players by player ID</h2>") cgicommon.writeln("<p>") cgicommon.writeln(""" Set the ratings of players in order, by player ID, which corresponds to the order in which they appeared in the list you put into the text
def show_rerate_button(tourney): tourney_name = tourney.get_name() cgicommon.writeln("<h2>Rerate players by player ID</h2>") cgicommon.writeln("<p>") cgicommon.writeln(""" Set the ratings of players in order, by player ID, which corresponds to the order in which they appeared in the list you put into the text box at the start of the tournament. The player at the top of the list (the lowest player ID) gets the highest rating, and the player at the bottom of the list (the highest player ID) gets the lowest rating. Any player with a rating of zero remains unchanged.""") cgicommon.writeln("</p>") cgicommon.writeln("<p>") cgicommon.writeln(""" This is useful if when you pasted in the player list you forgot to select the option which tells Atropine that they're in rating order, and now the Overachievers page thinks they're all seeded the same. """) cgicommon.writeln("</p>") cgicommon.writeln("<p>") cgicommon.writeln(""" If you press this button, it will overwrite all other non-zero ratings you may have given the players. That's why you need to tick the box as well. """) cgicommon.writeln("</p>") cgicommon.writeln("<p>") cgicommon.writeln("<form method=\"POST\" action=\"%s?tourney=%s\">" % (cgicommon.escape(baseurl), urllib.parse.quote_plus(tourney_name))) cgicommon.writeln("<input type=\"submit\" name=\"reratebyplayerid\" value=\"Rerate players by player ID\" />") cgicommon.writeln("<input type=\"checkbox\" name=\"reratebyplayeridconfirm\" id=\"reratebyplayeridconfirm\" style=\"margin-left: 20px\" />") cgicommon.writeln("<label for=\"reratebyplayeridconfirm\">Yes, I'm sure</label>") cgicommon.writeln("</form>") cgicommon.writeln("</p>")
def show_view_option_controls(tourney, form, options): if not options: return cgicommon.writeln( "<div class=\"teleostoptionheading\">Options for this screen mode</div>" ) for o in options: cgicommon.writeln("<div class=\"teleostoption\">") name_escaped = "teleost_option_" + cgicommon.escape(o.name, True) if o.value is None: value_escaped = "" else: value_escaped = cgicommon.escape(str(o.value), True) desc_escaped = cgicommon.escape(o.desc) # If $INDENT exists, replace it with a checkbox-width of empty space desc_escaped = re.sub( "\\$INDENT\\b", "<span style=\"visibility: hidden;\"><input type=\"checkbox\" name=\"_placeholder_%s\" /></span>" % (name_escaped), desc_escaped, 0) m = re.search("\\$CONTROL\\b", desc_escaped) if m: before_control = desc_escaped[0:m.start()] after_control = desc_escaped[m.end():] else: before_control = desc_escaped after_control = "" cgicommon.writeln(before_control) if o.name in checkbox_to_assoc_field: onclick_value = "var numberField = document.getElementById('%s'); var checkboxField = document.getElementById('%s'); numberField.disabled = !checkboxField.checked;" % ( "teleost_option_" + checkbox_to_assoc_field[o.name], name_escaped) else: onclick_value = None disabled_attr = "" if o.name in assoc_field_to_checkbox: for oo in options: if oo.name == assoc_field_to_checkbox[o.name]: try: value = int(oo.value) except ValueError: value = 0 if value: disabled_attr = "" else: disabled_attr = "disabled" break if o.control_type == countdowntourney.CONTROL_NUMBER: cgicommon.writeln( "<input type=\"number\" style=\"width: 5em;\" name=\"%s\" id=\"%s\" value=\"%s\" %s />" % (name_escaped, name_escaped, value_escaped, disabled_attr)) elif o.control_type == countdowntourney.CONTROL_CHECKBOX: if o.value is not None and int(o.value): checked_str = "checked" else: checked_str = "" cgicommon.writeln( "<input type=\"checkbox\" name=\"%s\" id=\"%s\" value=\"1\" %s %s />" % (name_escaped, name_escaped, checked_str, "" if not onclick_value else "onclick=\"" + re.sub("\"", "\\\"", onclick_value, 0) + "\"")) cgicommon.writeln( "<input type=\"hidden\" name=\"%s\" value=\"1\" />" % ("exists_checkbox_" + name_escaped)) cgicommon.writeln(after_control) cgicommon.writeln("</div>")
def show_conflict_resolution_example(existing_strategy): cgicommon.writeln("<div class=\"conflictresolutionexample\">") cgicommon.writeln( "<div class=\"conflictresolutionexampletitle\">Example:</div>") cgicommon.writeln("<table class=\"conflictresolutionexampletable\">") cgicommon.writeln("<tr>") cgicommon.writeln( "<th>Current result</th><th>Your submission</th><th>New result</th>") cgicommon.writeln("</tr>") cgicommon.writeln("<tr>") cgicommon.writeln( "<td>-</td><td>88-88</td><td class=\"cr_newresultcol\" id=\"cr_blanktononblank\">%s</td>" % ("88-88" if existing_strategy != CONFLICT_STRATEGY_DISCARD else "-")) cgicommon.writeln("</tr>") cgicommon.writeln("<tr>") cgicommon.writeln( "<td>77-77</td><td>88-88</td><td class=\"cr_newresultcol\" id=\"cr_nonblanktononblank\">%s</td>" % ("88-88" if existing_strategy in (CONFLICT_STRATEGY_FORCE, CONFLICT_STRATEGY_DO_NOT_EMBLANKIFY) else "77-77")) cgicommon.writeln("</tr>") cgicommon.writeln("<tr>") cgicommon.writeln( "<td>77-77</td><td>-</td><td class=\"cr_newresultcol\" id=\"cr_nonblanktoblank\">%s</td>" % ("-" if existing_strategy == CONFLICT_STRATEGY_FORCE else "77-77")) cgicommon.writeln("</tr>") cgicommon.writeln("</table>") cgicommon.writeln("</div>")
% (urllib.parse.quote_plus(name))) cgicommon.writeln("</td>") if show_display_link: cgicommon.writeln("<td class=\"tourneylistlink\">") cgicommon.writeln( "<a href=\"/cgi-bin/display.py?tourney=%s\">Full screen display</a>" % (urllib.parse.quote_plus(name))) cgicommon.writeln("</td>") cgicommon.writeln("</tr>") cgicommon.writeln("</table>") baseurl = "/cgi-bin/home.py" cgicommon.writeln("Content-Type: text/html; charset=utf-8") cgicommon.writeln("") cgicommon.print_html_head( "Create Tourney" if cgicommon.is_client_from_localhost() else "Atropine") form = cgi.FieldStorage() tourneyname = form.getfirst("name", "") order_by = form.getfirst("orderby", "mtime_d") request_method = os.environ.get("REQUEST_METHOD", "GET") cgicommon.writeln("<body>") cgicommon.writeln("<h1>Welcome to Atropine</h1>") if cgicommon.is_client_from_localhost():
#!/usr/bin/python3 import sys; import cgi; import cgicommon; form = cgi.FieldStorage(); tourney = form.getfirst("tourney", "NONE"); cgicommon.writeln("Content-Type: text/plain; charset=utf-8"); cgicommon.writeln(""); cgicommon.writeln("Hello, world!"); cgicommon.writeln("Tourney is %s" % tourney); sys.exit(0);
def fatal_error(text): cgicommon.print_html_head("Table Index") cgicommon.writeln("<body>") cgicommon.writeln("<p>%s</p>" % (cgicommon.escape(text))) cgicommon.writeln("</body></html>") sys.exit(1)
#!/usr/bin/python3 import sys import cgicommon import urllib.request, urllib.parse, urllib.error import cgi import cgitb cgitb.enable() cgicommon.writeln("Content-Type: text/html; charset=utf-8") cgicommon.writeln("") form = cgi.FieldStorage() tourney_name = form.getfirst("tourney") tourney = None cgicommon.set_module_path() import countdowntourney cgicommon.print_html_head("Standings: " + str(tourney_name)) cgicommon.writeln("<body>") cgicommon.assert_client_from_localhost() if tourney_name is None: cgicommon.writeln("<h1>No tourney specified</h1>") cgicommon.writeln("<p><a href=\"/cgi-bin/home.py\">Home</a></p>")
cgicommon.writeln("</div>") cgicommon.writeln("</body></html>") sys.exit(1) def int_or_none(s): if s is None: return None else: try: return int(s) except: return None cgicommon.writeln("Content-Type: text/html; charset=utf-8") cgicommon.writeln("") baseurl = "/cgi-bin/tableindex.py" form = cgi.FieldStorage() tourneyname = form.getfirst("tourney") tourney = None if tourneyname is None: fatal_error("No tourney name specified.") try: tourney = countdowntourney.tourney_open(tourneyname, cgicommon.dbdir) except countdowntourney.TourneyException as e: fatal_exception(e, None)
def get_name(self): return self.name def add_column(self, column): self.columns.append(column) def get_columns(self): return self.columns[:] baseurl = "/cgi-bin/sql.py" cgitb.enable() cgicommon.writeln("Content-Type: text/html; charset=utf-8") cgicommon.writeln("") cgicommon.print_html_head("Raw SQL interface") cgicommon.assert_client_from_localhost() form = cgi.FieldStorage() request_method = os.environ.get("REQUEST_METHOD", "") sql_text = None execute_sql = None tourney_name = form.getfirst("tourney") error_text = None error_text_context = "" db = None
#!/usr/bin/python3 import sys import cgicommon import urllib.request, urllib.parse, urllib.error import cgi import cgitb cgitb.enable() cgicommon.writeln("Content-Type: text/html; charset=utf-8") cgicommon.writeln("") form = cgi.FieldStorage() tourney_name = form.getfirst("tourney") tourney = None cgicommon.set_module_path() import countdowntourney cgicommon.print_html_head("Tuff luck: " + str(tourney_name)) cgicommon.writeln("<body>") cgicommon.assert_client_from_localhost() if tourney_name is None: cgicommon.writeln("<h1>No tourney specified</h1>") cgicommon.writeln("<p><a href=\"/cgi-bin/home.py\">Home</a></p>")
cgicommon.set_module_path() if csv_event_code is None: csv_event_code = "" if csv_game_format is None: csv_game_format = "" import countdowntourney if tourney_name is None: show_error("No tourney specified") sys.exit(0) if export_format is None: # No format specified: display a list of possible formats to choose from cgicommon.writeln("Content-Type: text/html; charset=utf-8") cgicommon.writeln("") started_html = True cgicommon.print_html_head("Tournament report: " + str(tourney_name)) cgicommon.writeln("<body>") tourney = countdowntourney.tourney_open(tourney_name, cgicommon.dbdir) cgicommon.show_sidebar(tourney) cgicommon.writeln("<div class=\"mainpane\">") html = """<h1>Choose export format</h1> <p> How do you want to export results?
def show_now_showing_frame(tourney): cgicommon.writeln( "<iframe class=\"displaypreviewframe\" src=\"/cgi-bin/display.py?tourney=%s\" height=\"300\" width=\"400\"></iframe>" % (urllib.parse.quote_plus(tourney.get_name())))
def show_error(err_str): cgicommon.writeln("Content-Type: text/html; charset=utf-8") cgicommon.writeln("") cgicommon.print_html_head("Tourney: %s" % tourney_name) cgicommon.writeln("<body>") cgicommon.show_sidebar(tourney) cgicommon.writeln("<div class=\"mainpane\">") cgicommon.writeln("<p><strong>%s</strong></p>" % err_str) cgicommon.writeln("</div>") cgicommon.writeln("</body>") cgicommon.writeln("</html>")
def show_view_preview(tourney, form, selected_view): cgicommon.writeln( "<iframe class=\"displaypreviewframe\" src=\"/cgi-bin/display.py?tourney=%s&mode=%d\" height=\"300\" width=\"400\"></iframe>" % (urllib.parse.quote_plus(tourney.get_name()), selected_view))
player = group[i] team_id = team_ids[i] player_teams.append((player.get_name(), team_id)) team_counts[team_id] += 1 pos += group_size # Assign each prune to no team for p in prunes: player_teams.append((p.get_name(), -1)) # Return the map of players to team IDs return player_teams cgicommon.writeln("Content-Type: text/html; charset=utf-8") cgicommon.writeln("") baseurl = "/cgi-bin/teamsetup.py" form = cgi.FieldStorage() tourneyname = form.getfirst("tourney") player_team_submit = form.getfirst("playerteamsubmit") random_assignment_submit = form.getfirst("randomassignmentsubmit") clear_teams_submit = form.getfirst("clearteams") random_group_size = int_or_none(form.getfirst("randomgroupsize")) if random_group_size is None: random_group_size = 6 tourney = None tourney_exception = None
#!/usr/bin/python3 import sys import cgicommon import cgi import cgitb import os cgitb.enable() cgicommon.writeln("Content-Type: text/html; charset=utf-8") cgicommon.writeln("") baseurl = "/cgi-bin/preferences.py" form = cgi.FieldStorage() tourney_name = form.getfirst("tourney") tourney = None request_method = os.environ.get("REQUEST_METHOD", "") cgicommon.set_module_path() cgicommon.print_html_head("Preferences") saved_prefs = False cgicommon.writeln("<body>") cgicommon.assert_client_from_localhost() cgicommon.writeln("""
def print_tourney_table(tourney_list, destination_page, show_last_modified, show_export_html_link=False, show_display_link=False): cgicommon.writeln("<table class=\"tourneylist\">") cgicommon.writeln("<tr>") cgicommon.writeln( "<th><a href=\"/cgi-bin/home.py?orderby=%s\">Name</a></th>" % ("name_d" if order_by == "name_a" else "name_a")) if show_last_modified: cgicommon.writeln( "<th><a href=\"/cgi-bin/home.py?orderby=%s\">Last modified</a></th>" % ("mtime_a" if order_by == "mtime_d" else "mtime_d")) if show_display_link or show_export_html_link: cgicommon.writeln( "<th colspan=\"%d\">Useful links</th>" % (2 if show_display_link and show_export_html_link else 1)) cgicommon.writeln("</tr>") for tourney_basename in tourney_list: name = tourney_basename[:-3] filename = os.path.join(cgicommon.dbdir, tourney_basename) st = os.stat(filename) modified_time = time.localtime(st.st_mtime) cgicommon.writeln("<tr>") cgicommon.writeln('<td class=\"tourneylistname\">') if destination_page: cgicommon.writeln( '<a href="%s?tourney=%s">%s</a>' % (cgicommon.escape(destination_page, True), urllib.parse.quote_plus(name), cgicommon.escape(name))) else: cgicommon.writeln(cgicommon.escape(name)) cgicommon.writeln('</td>') if show_last_modified: cgicommon.writeln("<td class=\"tourneylistmtime\">%s</td>" % (time.strftime("%d %b %Y %H:%M", modified_time))) if show_export_html_link: cgicommon.writeln("<td class=\"tourneylistlink\">") cgicommon.writeln( "<a href=\"/cgi-bin/export.py?tourney=%s&format=html\">Tourney report</a>" % (urllib.parse.quote_plus(name))) cgicommon.writeln("</td>") if show_display_link: cgicommon.writeln("<td class=\"tourneylistlink\">") cgicommon.writeln( "<a href=\"/cgi-bin/display.py?tourney=%s\">Full screen display</a>" % (urllib.parse.quote_plus(name))) cgicommon.writeln("</td>") cgicommon.writeln("</tr>") cgicommon.writeln("</table>")
% ("88-88" if existing_strategy in (CONFLICT_STRATEGY_FORCE, CONFLICT_STRATEGY_DO_NOT_EMBLANKIFY) else "77-77")) cgicommon.writeln("</tr>") cgicommon.writeln("<tr>") cgicommon.writeln( "<td>77-77</td><td>-</td><td class=\"cr_newresultcol\" id=\"cr_nonblanktoblank\">%s</td>" % ("-" if existing_strategy == CONFLICT_STRATEGY_FORCE else "77-77")) cgicommon.writeln("</tr>") cgicommon.writeln("</table>") cgicommon.writeln("</div>") cgitb.enable() cgicommon.writeln("Content-Type: text/html; charset=utf-8") cgicommon.writeln("") baseurl = "/cgi-bin/gameslist.py" form = cgi.FieldStorage() tourney_name = form.getfirst("tourney") tourney = None request_method = os.environ.get("REQUEST_METHOD", "") cgicommon.set_module_path() import countdowntourney cgicommon.print_html_head("Games: " + str(tourney_name))
cgitb.enable() cgicommon.set_module_path() import countdowntourney def int_or_none(s): if s is None: return None try: return int(s) except ValueError: return None cgicommon.writeln("Content-Type: text/html; charset=utf-8") cgicommon.writeln("") baseurl = "/cgi-bin/divsetup.py" form = cgi.FieldStorage() tourneyname = form.getfirst("tourney") num_divisions_required = int_or_none(form.getfirst("numdivisions")) division_size_multiple = int_or_none(form.getfirst("divsizemultiple")) div_sort = form.getfirst("divsort") if not div_sort or div_sort not in ["standings", "ratings"]: div_sort = "ratings" else: div_sort = "standings" if num_divisions_required is None: num_divisions_required = 1
def show_conflict_resolution_box(tourney, games, round_no, stored_revision_no, stored_revision_timestamp, form): tourney_name = tourney.get_name() existing_strategy = int_or_none(form.getfirst("conflictstrategy")) if existing_strategy is None: existing_strategy = CONFLICT_STRATEGY_DO_NOT_EMBLANKIFY cgicommon.writeln(""" <script> function update_conflict_resolution_example(value) { var blank_to_non_blank = document.getElementById("cr_blanktononblank"); var non_blank_to_non_blank = document.getElementById("cr_nonblanktononblank"); var non_blank_to_blank = document.getElementById("cr_nonblanktoblank"); if (value == 0) { /* CONFLICT_STRATEGY_FORCE */ blank_to_non_blank.innerHTML = "88-88"; non_blank_to_non_blank.innerHTML = "88-88"; non_blank_to_blank.innerHTML = "-"; } else if (value == 1) { /* CONFLICT_STRATEGY_DO_NOT_EMBLANKIFY */ blank_to_non_blank.innerHTML = "88-88"; non_blank_to_non_blank.innerHTML = "88-88"; non_blank_to_blank.innerHTML = "77-77"; } else if (value == 2) { /* CONFLICT_STRATEGY_ONLY_FILL_BLANKS */ blank_to_non_blank.innerHTML = "88-88"; non_blank_to_non_blank.innerHTML = "77-77"; non_blank_to_blank.innerHTML = "77-77"; } else if (value == 3) { /* CONFLICT_STRATEGY_DISCARD */ blank_to_non_blank.innerHTML = "-"; non_blank_to_non_blank.innerHTML = "77-77"; non_blank_to_blank.innerHTML = "77-77"; } } </script> """) cgicommon.writeln("<div class=\"conflictresolution\">") cgicommon.writeln( "<form method=\"POST\" action=\"%s?tourney=%s&round=%d\">" % (baseurl, urllib.parse.quote_plus(tourney_name), round_no)) cgicommon.writeln( "<input type=\"hidden\" name=\"tourney\" value=\"%s\" />" % (cgicommon.escape(tourney_name, True))) cgicommon.writeln("<input type=\"hidden\" name=\"round\" value=\"%d\" />" % (round_no)) cgicommon.writeln( "<input type=\"hidden\" name=\"revision\" value=\"%d\" />" % (stored_revision_no)) # Include the submitted scores in this conflict resolution form, so that # when the user presses "Resolve Conflicts" we remember what the original # submissions were. for g in games: input_name = "gamescore_%d_%d" % (g.round_no, g.seq) submitted_score = form.getfirst(input_name) if submitted_score is not None: cgicommon.writeln( "<input type=\"hidden\" name=\"%s\" value=\"%s\" />" % (cgicommon.escape(input_name), cgicommon.escape(submitted_score, True))) score = form.getfirst("gamescore_%d_%d" % (g.round_no, g.seq)) cgicommon.writeln("<div class=\"conflictresolutiontoprow\">") cgicommon.writeln("Last conflicting modification occurred at: %s" % (cgicommon.escape(stored_revision_timestamp))) cgicommon.writeln("</div>") cgicommon.writeln("<div class=\"conflictresolutionchoicerow\">") cgicommon.writeln("<div class=\"conflictresolutionradiobutton\">") cgicommon.writeln( "<input type=\"radio\" name=\"conflictstrategy\" id=\"conflictstrategydiscard\" value=\"%d\" onchange=\"update_conflict_resolution_example(this.value)\" %s />" % (CONFLICT_STRATEGY_DISCARD, "checked" if existing_strategy == CONFLICT_STRATEGY_DISCARD else "")) cgicommon.writeln("</div>") cgicommon.writeln("<div class=\"conflictresolutionlabel\">") cgicommon.writeln( "<label for=\"conflictstrategydiscard\">Discard my submission - go with what's currently in the database.</label>" ) cgicommon.writeln("</div>") cgicommon.writeln("</div>") cgicommon.writeln("<div class=\"conflictresolutionchoicerow\">") cgicommon.writeln("<div class=\"conflictresolutionradiobutton\">") cgicommon.writeln( "<input type=\"radio\" name=\"conflictstrategy\" id=\"conflictstrategyfillblanks\" value=\"%d\" onchange=\"update_conflict_resolution_example(this.value)\" %s />" % (CONFLICT_STRATEGY_ONLY_FILL_BLANKS, "checked" if existing_strategy == CONFLICT_STRATEGY_ONLY_FILL_BLANKS else "")) cgicommon.writeln("</div>") cgicommon.writeln("<div class=\"conflictresolutionlabel\">") cgicommon.writeln( "<label for=\"conflictstrategyfillblanks\">If a game currently has no result but my submission provides one, fill in that game's result with my submission. Discard any other changes.</label>" ) cgicommon.writeln("</div>") cgicommon.writeln("</div>") cgicommon.writeln("<div class=\"conflictresolutionchoicerow\">") cgicommon.writeln("<div class=\"conflictresolutionradiobutton\">") cgicommon.writeln( "<input type=\"radio\" name=\"conflictstrategy\" id=\"conflictstrategydonotemblankify\" value=\"%d\" onchange=\"update_conflict_resolution_example(this.value);\" %s />" % (CONFLICT_STRATEGY_DO_NOT_EMBLANKIFY, "checked" if existing_strategy == CONFLICT_STRATEGY_DO_NOT_EMBLANKIFY else "")) cgicommon.writeln("</div>") cgicommon.writeln("<div class=\"conflictresolutionlabel\">") cgicommon.writeln( "<label for=\"conflictstrategydonotemblankify\">If my submission has a result for a game, overwrite the existing result with my submission, but do not overwrite an existing result with a blank one.</label>" ) cgicommon.writeln("</div>") cgicommon.writeln("</div>") cgicommon.writeln("<div class=\"conflictresolutionchoicerow\">") cgicommon.writeln("<div class=\"conflictresolutionradiobutton\">") cgicommon.writeln( "<input type=\"radio\" name=\"conflictstrategy\" id=\"conflictstrategyforce\" value=\"%d\" onchange=\"update_conflict_resolution_example(this.value);\" %s />" % (CONFLICT_STRATEGY_FORCE, "checked" if existing_strategy == CONFLICT_STRATEGY_FORCE else "")) cgicommon.writeln("</div>") cgicommon.writeln("<div class=\"conflictresolutionlabel\">") cgicommon.writeln( "<label for=\"conflictstrategyforce\">Overwrite everything with my submission, even if that means overwriting existing results with blank results.</label>" ) cgicommon.writeln("</div>") cgicommon.writeln("</div>") show_conflict_resolution_example(existing_strategy) cgicommon.writeln("<div class=\"conflictresolutionbottomrow\">") cgicommon.writeln("<div class=\"conflictresolutionsubmit\">") cgicommon.writeln( "<input type=\"submit\" name=\"save\" value=\"Resolve Conflicts\" />") cgicommon.writeln("</div>") cgicommon.writeln("</div>") cgicommon.writeln("</form>") cgicommon.writeln("</div>")