def team_page(year, team_id):
    team = get_team(year, team_id)
    if team is None:
        return render_template("website/notFound.html",
                               route=Routes,
                               base=base_data(year),
                               team=team,
                               title="Team not found",
                               year=year,
                               user_info=get_user_information())
    team_authorization = get_team_authorization(Team.query.get(team_id))
    team_requests = []
    all_players = []
    if team_authorization['is_captain']:
        team_requests = (JoinLeagueRequest.query.filter(
            JoinLeagueRequest.team_id == team_id).filter(
                JoinLeagueRequest.pending == True)).all()
        team_requests = [request.json() for request in team_requests]
        all_players = [
            player.admin_json() for player in Player.query.filter(
                func.lower(Player.email) != func.lower(UNASSIGNED_EMAIL)).all(
                )
        ]
    return render_template("website/team.html",
                           route=Routes,
                           base=base_data(year),
                           team=team,
                           team_id=team_id,
                           title="Team - " + str(team['name']),
                           year=year,
                           user_info=get_user_information(),
                           team_requests=team_requests,
                           all_players=all_players,
                           team_authorization=team_authorization)
def player_page(year, player_id):
    player = Player.query.get(player_id)
    if player is None:
        return render_template("website/notFound.html",
                               route=Routes,
                               base=base_data(year),
                               title="Player not found",
                               year=year,
                               user_info=get_user_information())
    name = player.name
    years = []
    for team in player.teams:
        years.append((team.year, team.id))
    stats = []
    for entry in years:
        player = {}
        summary = player_summary(year=entry[0],
                                 team_id=entry[1],
                                 player_id=player_id)
        if name in summary:
            player = summary[name]
        else:
            player = {
                's': 0,
                'd': 0,
                'hr': 0,
                'ss': 0,
                'k': 0,
                'fo': 0,
                'fc': 0,
                'e': 0,
                'go': 0,
                'id': player_id,
                'rbi': 0,
                'avg': 0.000,
                'bats': 0
            }
        player['team'] = str(Team.query.get(entry[1]))
        player['team_id'] = entry[1]
        player['year'] = entry[0]
        stats.append(player)
    return render_template("website/player.html",
                           route=Routes,
                           base=base_data(year),
                           stats=stats,
                           title="Player Stats",
                           name=name,
                           year=year,
                           user_info=get_user_information())
Example #3
0
def events_page(year):
    if year in EVENTS:
        return render_template("website/events.html",
                               dates=EVENTS[year],
                               route=Routes,
                               base=base_data(year),
                               title="Events",
                               year=year,
                               user_info=get_user_information())
    else:
        return render_template("website/notFound.html",
                               year=year,
                               route=Routes,
                               base=base_data(year),
                               title="Not Found",
                               user_info=get_user_information())
def sponsors_page(year):
    return render_template("website/sponsors.html",
                           route=Routes,
                           base=base_data(year),
                           title="Sponsors",
                           year=year,
                           user_info=get_user_information())
def rules_fields(year):
    return render_template("website/fields-and-rules.html",
                           route=Routes,
                           base=base_data(year),
                           title="Fields & Rules",
                           year=year,
                           user_info=get_user_information())
def league_not_found(year):
    return render_template("website/leagueNotFound.html",
                           route=Routes,
                           base=base_data(year),
                           title="League not found",
                           year=year,
                           user_info=get_user_information())
Example #7
0
def promos_page(year):
    return render_template("website/promos.html",
                           route=Routes,
                           base=base_data(year),
                           title="Pump-Up Videos",
                           year=year,
                           user_info=get_user_information())
def sponsor_breakdown(year):
    return render_template("website/sponsor_breakdown.html",
                           route=Routes,
                           base=base_data(year),
                           title="ESPYS Breakdown by Sponsor",
                           year=year,
                           teams=get_teams(year),
                           user_info=get_user_information())
def about(year):
    return render_template("website/about.html",
                           route=Routes,
                           base=base_data(year),
                           title="About",
                           year=year,
                           games=get_upcoming_games(year),
                           user_info=get_user_information())
def stats_page(year):
    players = player_summary(year=year)
    return render_template("website/stats.html",
                           route=Routes,
                           base=base_data(year),
                           title="Players Stats",
                           year=year,
                           players=players,
                           user_info=get_user_information())
Example #11
0
def index(year):
    return render_template("website/index.html",
                           route=Routes,
                           base=base_data(year),
                           title="Recent news",
                           year=year,
                           games=get_upcoming_games(year),
                           news=get_summaries(year),
                           user_info=get_user_information())
def captain_batting_app(team_id: int):
    """Navigate to the captain score app"""
    year = datetime.now().year
    return render_template("website/captain_batting_app.html",
                           route=Routes,
                           base=base_data(year),
                           title="Captain In-Game Batting App",
                           year=year,
                           team_id=team_id,
                           user_info=get_user_information())
def sponsor_page(year, sponsor_id):
    sponsor = get_sponsor_map().get(sponsor_id, None)
    if sponsor is None:
        page = render_template("website/notFound.html",
                               route=Routes,
                               base=base_data(year),
                               title="Not Found",
                               year=year,
                               user_info=get_user_information())
    else:
        page = render_template("website/sponsor.html",
                               route=Routes,
                               base=base_data(year),
                               sponsor=sponsor,
                               title="Sponsor | " +
                               sponsor.get('sponsor_name', 'No Name'),
                               year=year,
                               user_info=get_user_information())
    return page
Example #14
0
def checkout_post(year, date, file_name):
    file_name = date + "_" + file_name
    template = "/".join(["website", "posts", str(year), file_name])
    if template.endswith(".html"):
        return render_template(template,
                               route=Routes,
                               base=base_data(year),
                               title="Posts",
                               year=year,
                               games=get_upcoming_games(year),
                               user_info=get_user_information())
    else:
        return render_template("website/notFound.html",
                               route=Routes,
                               base=base_data(year),
                               title="Posts not Found",
                               year=year,
                               games=get_upcoming_games(year),
                               user_info=get_user_information())
def leaders_page(year):
    women = get_league_leaders("ss", year=year)[:5]
    men = get_league_leaders("hr", year=year)[:5]
    return render_template("website/new-leaders.html",
                           route=Routes,
                           base=base_data(year),
                           men=men,
                           women=women,
                           title="League Leaders",
                           year=year,
                           user_info=get_user_information())
def standings(league_id, year):
    league = get_league_map().get(league_id, None)
    if league is None:
        return redirect(url_for("league_not_found", year=year))
    divisions = get_divisions_for_league_and_year(year, league_id)
    if len(divisions) == 1:
        divisions = []
    return render_template("website/standings.html",
                           route=Routes,
                           base=base_data(year),
                           league=league,
                           divisions=divisions,
                           title="Standings",
                           year=year,
                           user_info=get_user_information())
def all_time_leaders_page(year):
    hrSingleSeason = get_league_leaders("hr")
    ssSingleSeason = get_league_leaders("ss")
    hrAllSeason = get_league_leaders("hr", group_by_team=True)
    ssAllSeason = get_league_leaders("ss", group_by_team=True)
    return render_template("website/all-time-leaders.html",
                           route=Routes,
                           base=base_data(year),
                           hrSingleSeason=hrSingleSeason,
                           ssSingleSeason=ssSingleSeason,
                           hrAllSeason=hrAllSeason,
                           ssAllSeason=ssAllSeason,
                           title="League Leaders",
                           year=year,
                           user_info=get_user_information())