Ejemplo n.º 1
0
def add_a_player():
    # Set back tournament's data to an instance of class Tournament
    tournament = convert_to_instance()

    player_form = PlayerForm()

    if player_form.validate_on_submit():
        player = Player(player_form.first_name.data,
                        player_form.last_name.data,
                        player_form.date_of_birth.data,
                        player_form.gender.data,
                        player_form.rank.data,
                        score_of_round=0,
                        final_score_of_tournament=0)
        add_a_player_to_database(player)
        tournament.new_tournament_players(player)
        add_tournament_to_database(tournament)
        number_of_players_to_add = len(tournament.list_of_players)

        return render_template(
            'tournament_created.html',
            tournament=tournament,
            number_of_players_to_add=number_of_players_to_add)

    return render_template('add_a_player.html',
                           player_form=player_form,
                           tournament=tournament)
Ejemplo n.º 2
0
def tournament_created():
    # Set back tournament's data to an instance of class Tournament
    tournament = convert_to_instance()
    number_of_players_to_add = len(tournament.list_of_players)
    return render_template('tournament_created.html',
                           tournament=tournament,
                           number_of_players_to_add=number_of_players_to_add)
Ejemplo n.º 3
0
def enter_score():
    # Set back tournament's data to an instance of class Tournament
    tournament = convert_to_instance()
    round_name = tournament.rounds_names[len(tournament.rounds_names) - 1]
    matches = tournament.list_of_round[round_name]
    if len(tournament.list_of_players) == tournament.number_of_players:
        tournament.list_of_players = []
    score_already_enter = int(len(tournament.list_of_players) / 2)
    form = RoundScore()
    if form.validate_on_submit():
        tournament.enter_score_of_match(matches[score_already_enter][0],
                                        form.score0.data)
        tournament.enter_score_of_match(matches[score_already_enter][1],
                                        form.score1.data)

        tournament.list_of_players.append(matches[score_already_enter][0])
        tournament.list_of_players.append(matches[score_already_enter][1])

        number_of_players_with_scores = len(tournament.list_of_players)
        number_of_round = len(tournament.rounds_names)
        round_name = tournament.rounds_names[len(tournament.rounds_names) - 1]

        add_tournament_to_database(tournament)

        return render_template(
            'players_scores_confirmation.html',
            round_name=round_name,
            tournament=tournament,
            number_of_round=number_of_round,
            number_of_players_with_scores=number_of_players_with_scores)

    return render_template('enter_score.html',
                           matches=matches,
                           form=form,
                           score_already_enter=score_already_enter)
Ejemplo n.º 4
0
def winner_is():
    # Set back tournament's data to an instance of class Tournament
    tournament = convert_to_instance()
    tournament.list_of_players = tournament.score_of_the_tournament()
    winner = tournament.list_of_players[0]
    print(tournament.list_of_players)
    return render_template('winner_is.html',
                           tournament=tournament,
                           winner=winner)
Ejemplo n.º 5
0
def match_players_for_the_round():
    # Set back tournament's data to an instance of class Tournament
    tournament = convert_to_instance()

    tournament.list_of_round = tournament.matching_players()

    add_tournament_to_database(tournament)

    return redirect(url_for('display_match_of_the_round'))
Ejemplo n.º 6
0
def sort_players():
    # Set back tournament's data to an instance of class Tournament
    tournament = convert_to_instance()

    # Sort players by rank
    tournament.sorted_players = tournament.sorted_players_for_a_round()

    # Update data of the tournament
    add_tournament_to_database(tournament)
    return redirect(url_for('name_the_round'))
Ejemplo n.º 7
0
def display_match_of_the_round():
    # Set back tournament's data to an instance of class Tournament
    tournament = convert_to_instance()

    round_name = tournament.rounds_names[len(tournament.rounds_names) - 1]
    matches = tournament.list_of_round[round_name]
    print(tournament.list_of_round)

    return render_template('display_match_of_the_round.html',
                           round_name=round_name,
                           tournament=tournament,
                           matches=matches)
Ejemplo n.º 8
0
def name_the_round():
    # Set back tournament's data to an instance of class Tournament
    tournament = convert_to_instance()

    form = RoundForm()
    if form.validate_on_submit():
        # Add the name of the round to the tournament's data
        tournament.name_the_round(form.round_name.data)
        # Update data of the tournament
        add_tournament_to_database(tournament)
        return redirect(url_for('match_players_for_the_round'))

    return render_template('name_the_round.html', form=form)