コード例 #1
0
def leagues():
    teams = team_repository.select_all()
    matches = match_repository.select_all()
    stats = stat_repository.generate_stats(teams, matches)
    games_won = stat_repository.generate_games_won(teams, matches)
    games_drawn = stat_repository.generate_games_drawn(teams, matches)
    games_lost = stat_repository.generate_games_lost(teams, matches)
    goals_for = stat_repository.generate_goals_for(teams, matches)
    goals_against = stat_repository.generate_goals_against(teams, matches)
    games_form = stat_repository.generate_games_form(teams, matches)

    league_points = stat_repository.generate_league_points(teams, matches)
    today = datetime.now()
    today = today.strftime("%d/%m/%Y %H:%M:%S")

    return render_template("leagues/show.html",
                           teams=teams,
                           stats=stats,
                           games_won=games_won,
                           games_drawn=games_drawn,
                           games_lost=games_lost,
                           league_points=league_points,
                           goals_for=goals_for,
                           goals_against=goals_against,
                           games_form=games_form,
                           today=today)
コード例 #2
0
def show_team_matches(id):
    matches = match_repository.select_all()
    teams = team_repository.select_all()

    return render_template("matches/team_matches.html",
                           matches=matches,
                           teams=teams,
                           team_name=id)
コード例 #3
0
def show_team(id):
    team = team_repository.select(id)
    teams = team_repository.select_all()
    fixtures = fixture_repository.select_all()
    return render_template("clubs/show.html",
                           team=team,
                           teams=teams,
                           fixtures=fixtures)
コード例 #4
0
def edit_match(id):
    match = match_repository.select(id)

    home_team = team_repository.select(match.home_team_id)
    away_team = team_repository.select(match.away_team_id)

    teams = team_repository.select_all()
    return render_template('matches/edit.html',
                           match=match,
                           home_team=home_team,
                           away_team=away_team,
                           teams=teams)
コード例 #5
0
def setup_new_player(player):
    add_to_overall_league(player)

    # Player Teams
    for team in team_repository.select_all():
        player_team_repository.save(PlayerTeam(player, team))

    # Player Groups
    for group in group_repository.select_all():
        player_teams = []
        for team in group.teams:
            player_teams.append(
                player_team_repository.select_by_player_and_team(player, team))
        player_group_repository.save(
            PlayerGroup(player, group.name, player_teams))

    # Predictions
    for match in match_repository.select_all():
        home_player_team = player_team_repository.select_by_player_and_team(
            player, match.team_1)
        away_player_team = player_team_repository.select_by_player_and_team(
            player, match.team_2)
        prediction_repository.save(
            Prediction(player, match, home_player_team, away_player_team))
コード例 #6
0
def edit_team(id):
    fixture = fixture_repository.select(id)
    teams = team_repository.select_all()
    return render_template('fixtures/edit.html', fixture=fixture, teams=teams)
コード例 #7
0
def show_matches():
    matches = match_repository.select_all()
    teams = team_repository.select_all()

    return render_template("matches/show.html", matches=matches, teams=teams)
コード例 #8
0
def new_game():
    teams = team_repository.select_all()
    return render_template("games/new.html", teams = teams)
コード例 #9
0
def edit_team(id):
    team = team_repository.select(id)
    teams = team_repository.select_all()
    return render_template("teams/edit.html", team=team, teams=teams)
コード例 #10
0
def edit_player(id):
    player = player_repository.select(id)
    teams = team_repository.select_all()
    return render_template('clubs/players/edit.html',
                           player=player,
                           teams=teams)
コード例 #11
0
def new_player():
    teams = team_repository.select_all()
    return render_template("clubs/players/new.html", teams=teams)
コード例 #12
0
def edit_fixture(id):
    fixture = fixture_repository.select(id)
    teams = team_repository.select_all()
    return render_template("/fixtures/edit.html", teams = teams, fixture=fixture)
コード例 #13
0
def new_fixture():
    team1 = team_repository.select_all()
    team2 = team_repository.select_all()
    return render_template("/fixtures/new.html", team1=team1, team2=team2)
コード例 #14
0
def show_teams():
    teams = []
    selected_teams = team_repository.select_all()
    for team in selected_teams:
        teams.append(team.__dict__)
    return make_response(jsonify(teams)), 200
コード例 #15
0
def new_match():
    teams = team_repository.select_all()
    return render_template("matches/new.html", teams=teams)
コード例 #16
0
def players():
    players = player_repository.select_all()
    teams = team_repository.select_all()
    return render_template("clubs/players/index.html",
                           players=players,
                           teams=teams)
コード例 #17
0
def main():
    teams = team_repository.select_all()
    return render_template('index.html', teams=teams)
コード例 #18
0
def show_team(id):
    player = player_repository.select(id)
    teams = team_repository.select_all()
    return render_template("clubs/players/show.html",
                           player=player,
                           teams=teams)
コード例 #19
0
def tables():
    teams = team_repository.select_all()
    return render_template('tables/index.html', teams=teams)
コード例 #20
0
csv_file.close()

# Leagues
league_1 = League("Overall")
league_1.join_code = "0000-0000"
league_repository.save(league_1)

# Player Leagues
player_league_1 = PlayerLeague(league_1, player_1)
player_league_repository.save(player_league_1)
player_league_2 = PlayerLeague(league_1, player_2)
player_league_repository.save(player_league_2)

# Player Teams
for team in team_repository.select_all():
    player_team_repository.save(PlayerTeam(player_1, team))

# Player Groups
for group in group_repository.select_all():
    player_teams = []
    for team in group.teams:
        player_teams.append(
            player_team_repository.select_by_player_and_team(player_1, team))
    player_group_repository.save(
        PlayerGroup(player_1, group.name, player_teams))

# Predictions
for match in match_repository.select_all():
    home_player_team = player_team_repository.select_by_player_and_team(
        player_1, match.team_1)
コード例 #21
0
team_repository.delete_all()
league_repository.delete_all()
game_repository.delete_all()
# above methods will empty the DB's before they are populated with below info/methods

team1 = Team("Aberdeen Roughnecks")
team_repository.save(team1)
team2 = Team("Dumfries Hunters")
team_repository.save(team2)
team3 = Team("Clyde Valley Blackhawks")
team_repository.save(team3)
team4 = Team("West Coast Trojans")
team_repository.save(team4)
# above code will create each team and save to the DB

team_repository.select_all()
# above method will display the teams

league1 = League("NFC Division 1", team1)
league_repository.save(league1)
# above will create a league and save to DB

league_repository.select_all()
# above will take all info that's gone into the league
# need to input data for the league (table) to be able to populate it with game_wins

game1 = Game(team1, team2, "game week 1", league1)
game_repository.save(game1)
game2 = Game(team3, team4, "game week 1", league1)
game_repository.save(game2)
コード例 #22
0
def new_team():
    teams = team_repository.select_all()
    return render_template("teams/new.html", all_teams=teams)
コード例 #23
0
def new_task():
    teams = team_repository.select_all()
    games = game_repository.select_all()
    return render_template("leagues/new.html", teams=teams, games=games)
コード例 #24
0
def teams():
    teams = team_repository.select_all()
    return render_template("teams/index.html", teams = teams)
コード例 #25
0
def fixtures():
    fixtures = fixture_repository.select_all()
    teams = team_repository.select_all()
    return render_template("fixtures/index.html",
                           all_fixtures=fixtures,
                           teams=teams)
コード例 #26
0
def edit_game(id):
    teams = team_repository.select_all()
    game = game_repository.select(id)
    # team_1 = game.team_1
    # team_2 = game.team_2
    return render_template("games/edit.html", game = game, teams = teams)
コード例 #27
0
def matches():
    matches = matches_repository.select_all()
    teams = team_repository.select_all()

    return render_template("matches/index.html", matches=matches, teams=teams)