Ejemplo n.º 1
0
    def GET(self, id_round):
        # Returns a matches for each round
        playerMatches = trn.roundMatches(id_round)
        # Returns id by tournament
        id_tournament = trn.reportIdTournament(id_round)
        # Returns if exist a match for a round
        matchState = trn.reportMatchByRound(id_round)

        # Create a list of inputs with information about matches to register the result
        for playerMatch in playerMatches:
            name = "match%d" % playerMatch[0]
            self.dynamic.add_input(
                web.form.Dropdown(
                    name,
                    [
                        (str(playerMatch[3]) + "." + str(playerMatch[4]), playerMatch[1]),
                        (str(playerMatch[4]) + "." + str(playerMatch[3]), playerMatch[2]),
                        (str(playerMatch[3]) + "_" + str(playerMatch[4]), "Tied"),
                    ],
                )
            )

        self.dynamic.add_input(
            web.form.Button("save", type="submit", description="Save", class_="btn btn-lg btn-warning pull-right")
        )
        return render.result_match(id_round, id_tournament, playerMatches, matchState, self.dynamic)
Ejemplo n.º 2
0
 def GET(self, id_round):
     # Returns matches for a round
     playerMatches = trn.roundMatches(id_round)
     # Returns id for a tournament
     id_tournament = trn.reportIdTournament(id_round)
     # Returns true if exist a match for a round
     matchStatus = trn.reportMatchByRound(id_round)
     # Returns true if exist a result for match
     resultStatus = trn.reportResultByMatch(id_round)
     # Return a Bye Player
     byePlayer = trn.reportByePlayer(id_round)
     return render.player_matches(id_round, id_tournament, playerMatches, matchStatus, byePlayer, resultStatus)
Ejemplo n.º 3
0
    def POST(self, id_round):
        list_inputs = web.input()
        # get bye player
        byePlayer = trn.reportIdByePlayer(id_round)

        for key in list_inputs:
            if key != "save":
                idPlayers = list_inputs[key].encode("ascii", "ignore")
                # Split id for each input to get the id which will be record
                separatorPlayers = str.find(idPlayers, ".")
                if separatorPlayers != -1:
                    winner = idPlayers[:separatorPlayers]
                    loser = idPlayers[separatorPlayers + 1 :]
                    tied = None
                else:
                    separatorPlayers = str.find(idPlayers, "_")
                    winner = idPlayers[:separatorPlayers]
                    loser = idPlayers[separatorPlayers + 1 :]
                    tied = idPlayers
                # Records match results.
                trn.saveResultMatch(id_round, int(key[5:]), winner, loser, tied)

        # Update result of bye player to sum a win according to the rules
        trn.updateScoreboardBye(id_round, byePlayer)

        # Returns id tournament
        id_tournament = trn.reportIdTournament(id_round)
        # Returns next round
        id_round_next = trn.getNextRound(id_round, id_tournament)

        if id_round_next != None:
            # Returns standings for actual round
            standings = trn.roundStandings(id_round)
            for standing in standings:
                # register standing for next round
                trn.registerStandings(
                    id_round_next, standing[0], standing[2], standing[3], standing[4], standing[5], "Insert"
                )

        url = "/player_matches/%d" % int(id_round)
        raise web.seeother(url)
Ejemplo n.º 4
0
 def GET(self, id_round):
     # Returns standings for round
     playerStandings = trn.roundStandings(id_round)
     # Returns id for a tournament
     id_tournament = trn.reportIdTournament(id_round)
     return render.player_standings(id_round, id_tournament, playerStandings)