def input_player(id):
    league = league_repo.select(id)
    teams = league_repo.teams(league)
    return render_template("new_leagues/add_players.html",
                           title="Create New League",
                           league=league,
                           teams=teams,
                           creating=True)
def input_teams(id, no_teams, team_no):
    league = league_repo.select(id)
    return render_template("new_leagues/add_teams.html",
                           title="Create New League",
                           league=league,
                           team_no=team_no,
                           no_teams=no_teams,
                           creating=True)
Esempio n. 3
0
def league_results(id):
    league = league_repo.select(id)
    teams = league_repo.teams(league)
    games = league_repo.results(league)
    return render_template("leagues/results.html",
                           title=league.sport + " - " + league.name,
                           league=league,
                           teams=teams,
                           games=games)
Esempio n. 4
0
def show_league(id):
    league = league_repo.select(id)
    teams = league_repo.teams(league)
    top_scorer = league_repo.top_scorer(league)
    return render_template("leagues/show.html",
                           title=league.sport + " - " + league.name,
                           league=league,
                           teams=teams,
                           top_scorer=top_scorer)
Esempio n. 5
0
def select(id):
    team = None
    sql = "SELECT * FROM teams WHERE id = %s"
    values = [id]
    result = run_sql(sql, values)[0]

    if result is not None:
        league = league_repo.select(result['league_id'])
        team = Team(league, result['name'], result['games_played'], result['wins'], result['draws'], result['losses'], result['goals_for'], result['goals_against'], result['goal_difference'], result['points'], result['id'])
    return team
Esempio n. 6
0
def edit_league(id):
    league = league_repo.select(id)
    # teams = league_repo.teams(league)
    players = league_repo.players(league)
    games = league_repo.unfinished_gemas(league)
    return render_template("games/update-league.html",
                           title="Update Games",
                           league=league,
                           players=players,
                           games=games,
                           editing=True)
Esempio n. 7
0
def select_all():
    teams = []

    sql = "SELECT * FROM teams ORDER BY name ASC"
    results = run_sql(sql)

    for result in results:
        league = league_repo.select(result['league_id'])
        team = Team(league, result['name'], result['games_played'], result['wins'], result['draws'], result['losses'], result['goals_for'], result['goals_against'], result['goal_difference'], result['points'], result['id'])
        teams.append(team)
    return teams
def add_teams(id, no_teams, team_no):
    league = league_repo.select(id)
    name = request.form['name']
    team = Team(league, name)
    team_repo.save(team)
    if team_no == no_teams:
        return redirect(f"/edit/league/{league.id}/generate-fixtures")
    else:
        team_no = int(team_no)
        team_no += 1
        return redirect(
            f"/edit/league/{league.id}/add-teams/{no_teams}/{team_no}")
Esempio n. 9
0
def games(team):
    games = []

    sql = "SELECT * FROM games WHERE team_1_id = %s OR team_2_id = %s ORDER BY game_no ASC"
    values = [team.id, team.id]
    results = run_sql(sql, values)
    for result in results:
        team_1 = team if result['team_1_id'] == team.id else select(result['team_1_id'])
        team_2 = team if result['team_2_id'] == team.id else select(result['team_2_id'])
        league = league_repo.select(result['league_id'])
        game = Game(team_1, team_2, league, result['round_no'], result['game_no'], result['team_1_score'], result['team_2_score'], result['started'], result['finished'], result['id'])
        games.append(game)
    return games
Esempio n. 10
0
def select(id):
    game = None
    sql = "SELECT * FROM games WHERE id = %s"
    values = [id]
    result = run_sql(sql, values)[0]

    if result is not None:
        team_1 = team_repo.select(result['team_1_id'])
        team_2 = team_repo.select(result['team_2_id'])
        league = league_repo.select(result['league_id'])
        game = Game(team_1, team_2, league, result['round_no'],
                    result['game_no'], result['team_1_score'],
                    result['team_2_score'], result['started'],
                    result['finished'], result['id'])
    return game
Esempio n. 11
0
def league_fixtures_by_round(id, round_no):
    league = league_repo.select(id)
    teams = league_repo.teams(league)
    current_round = int(round_no)
    max_round = league_repo.get_max_round(league)
    if current_round is not None:
        games = league_repo.current_games(league, current_round)
    else:
        games = []
    return render_template("leagues/current_round.html",
                           title=league.sport + " - " + league.name,
                           league=league,
                           teams=teams,
                           games=games,
                           round_no=current_round,
                           max_round=max_round)
Esempio n. 12
0
def select_all():
    games = []

    sql = "SELECT * FROM games"
    results = run_sql(sql)

    for result in results:
        team_1 = team_repo.select(result['team_1_id'])
        team_2 = team_repo.select(result['team_2_id'])
        league = league_repo.select(result['league_id'])
        game = Game(team_1, team_2, league, result['round_no'],
                    result['game_no'], result['team_1_score'],
                    result['team_2_score'], result['started'],
                    result['finished'], result['id'])
        games.append(game)
    return games
Esempio n. 13
0
import repositories.league_repo as league_repo
from models.league_type import LeagueType
import repositories.league_type_repo as league_type_repo
from models.player import Player
import repositories.player_repo as player_repo
from models.playlist import Playlist
import repositories.playlist_repo as playlist_repo
from models.possible_game import PossibleGame
import repositories.possible_game_repo as possible_game_repo
from models.red import Red
import repositories.red_repo as red_repo
from models.team import Team
import repositories.team_repo as team_repo
from models.yellow import Yellow
import repositories.yellow_repo as yellow_repo


league = league_repo.select(4)
games = game_repo.generate_fixture_list(league)
for game in games:
    game_repo.save(game)





    



pdb.set_trace()
from models.league import League
import repositories.league_repo as league_repo
from models.league_type import LeagueType
import repositories.league_type_repo as league_type_repo
from models.player import Player
import repositories.player_repo as player_repo
from models.playlist import Playlist
import repositories.playlist_repo as playlist_repo
from models.possible_game import PossibleGame
import repositories.possible_game_repo as possible_game_repo
from models.red import Red
import repositories.red_repo as red_repo
from models.team import Team
import repositories.team_repo as team_repo
from models.yellow import Yellow
import repositories.yellow_repo as yellow_repo

league = league_repo.select(3)
games = game_repo.generate_fixture_list(league)
for game in games:
    game_repo.save(game)

league = league_repo.select(1)
games = game_repo.generate_fixture_list(league)
for game in games:
    game_repo.save(game)

league = league_repo.select(2)
games = game_repo.generate_fixture_list(league)
for game in games:
    game_repo.save(game)
def generate_fixtures(id):
    league = league_repo.select(id)
    games = game_repo.generate_fixture_list(league)
    for game in games:
        game_repo.save(game)
    return redirect(f"/edit/league/{league.id}/add-players")