Add season statistics switching
This commit is contained in:
19
formula10.py
19
formula10.py
@ -18,6 +18,25 @@ def index():
|
||||
return render_template("index.jinja")
|
||||
|
||||
|
||||
@app.route("/seasons/")
|
||||
def default_season():
|
||||
return redirect("/seasons/2023/p10")
|
||||
|
||||
|
||||
@app.route("/seasons/<year>/")
|
||||
def default_statistic(year):
|
||||
return redirect("/seasons/" + year + "/p10")
|
||||
|
||||
|
||||
@app.route("/seasons/<year>/<statistic>/")
|
||||
def seasons(year, statistic):
|
||||
seasons = Season.query.all()
|
||||
|
||||
return render_template(
|
||||
"season.jinja", year=year, statistic=statistic, seasons=seasons
|
||||
)
|
||||
|
||||
|
||||
# @app.route("/teams", methods=["GET", "POST"])
|
||||
# def teams():
|
||||
# if request.method == "POST":
|
||||
|
||||
4
static/style/bootstrap-custom.css
vendored
Normal file
4
static/style/bootstrap-custom.css
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
.dropdown-menu {
|
||||
max-height: 250px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
@ -1,37 +1,45 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
{% macro sentence_case(text) %}
|
||||
{{ text[0] | upper }}{{ text[1:] }}
|
||||
{% endmacro %}
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
<!-- Title -->
|
||||
<title>{% block title %}{% endblock title %}</title>
|
||||
<link rel="icon" href="../static/image/favicon.svg" sizes="any" type="image/svg+xml">
|
||||
<!-- Title -->
|
||||
<title>{% block title %}{% endblock title %}</title>
|
||||
<link rel="icon" href="/../static/image/favicon.svg" sizes="any" type="image/svg+xml">
|
||||
|
||||
<!-- Bootstrap -->
|
||||
<link href="../static/style/bootstrap.min.css" rel="stylesheet">
|
||||
<script src="../static/script/bootstrap.bundle.min.js"></script>
|
||||
<!-- Bootstrap -->
|
||||
<link href="/../static/style/bootstrap.min.css" rel="stylesheet">
|
||||
<script src="/../static/script/bootstrap.bundle.min.js"></script>
|
||||
<link href="/../static/style/bootstrap-custom.css" rel="stylesheet">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<nav class="navbar navbar-expand-lg bg-body-tertiary">
|
||||
<div class="container-fluid">
|
||||
<a class="navbar-brand" href="/">
|
||||
<img src="../static/image/f1_logo.svg" alt="Logo" width="120" height="30" class="d-inline-block align-text-top">
|
||||
Formula <i>10</i>
|
||||
</a>
|
||||
<div class="collapse navbar-collapse" id="navbarNavAltMarkup">
|
||||
<div class="navbar-nav">
|
||||
{# <a class="nav-link {% if page == 'teams' %}active{% endif %}" href="/teams">Teams</a> #}
|
||||
{# <a class="nav-link {% if page == 'drivers' %}active{% endif %}" href="/drivers">Drivers</a> #}
|
||||
</div>
|
||||
</div>
|
||||
<nav class="navbar navbar-expand-lg bg-body-tertiary">
|
||||
<div class="container-fluid">
|
||||
<a class="navbar-brand" href="/">
|
||||
<img src="/../static/image/f1_logo.svg" alt="Logo" width="120" height="30" class="d-inline-block align-text-top">
|
||||
Formula <i>10</i>
|
||||
</a>
|
||||
<div class="collapse navbar-collapse" id="navbarNavAltMarkup">
|
||||
<div class="navbar-nav">
|
||||
{# <a class="nav-link {% if page == 'teams' %}active{% endif %}" href="/teams">Teams</a> #}
|
||||
{# <a class="nav-link {% if page == 'drivers' %}active{% endif %}" href="/drivers">Drivers</a> #}
|
||||
<a class="nav-link {% if page == 'seasons' %}active{% endif %}" href="/seasons">Seasons</a>
|
||||
{% block navbar_links %}{% endblock navbar_links %}
|
||||
</div>
|
||||
</nav>
|
||||
</div>
|
||||
{% block navbar_extra %}{% endblock navbar_extra %}
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
{% block body %}{% endblock body %}
|
||||
{% block body %}{% endblock body %}
|
||||
|
||||
</body>
|
||||
|
||||
|
||||
40
templates/season.jinja
Normal file
40
templates/season.jinja
Normal file
@ -0,0 +1,40 @@
|
||||
{% extends 'base.jinja' %}
|
||||
{% block title %}Formula 10 - {{year}} Season{% endblock title %}
|
||||
|
||||
{% block navbar_extra %}
|
||||
<div class="d-flex gap-2">
|
||||
<div class="dropdown">
|
||||
<button class="btn btn-secondary dropdown-toggle" type="button" data-bs-toggle="dropdown">
|
||||
{{ year }}
|
||||
</button>
|
||||
<ul class="dropdown-menu">
|
||||
{% for season in seasons %}
|
||||
<li><a class="dropdown-item {% if season.year | int == year | int %}active{% endif %}"
|
||||
href="/seasons/{{ season.year }}/{{ statistic }}">{{ season.year }}</a></li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
<div class="dropdown">
|
||||
<button class="btn btn-secondary dropdown-toggle" type="button" data-bs-toggle="dropdown">
|
||||
{{ sentence_case(statistic) }}
|
||||
</button>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a class="dropdown-item {% if statistic == 'p10' %}active{% endif %}" href="/seasons/{{ year }}/p10">P10</a>
|
||||
</li>
|
||||
<li><a class="dropdown-item {% if statistic == 'races' %}active{% endif %}"
|
||||
href="/seasons/{{ year }}/races">Races</a></li>
|
||||
<li><a class="dropdown-item {% if statistic == 'drivers' %}active{% endif %}"
|
||||
href="/seasons/{{ year }}/drivers">Drivers</a></li>
|
||||
<li><a class="dropdown-item {% if statistic == 'constructors' %}active{% endif %}"
|
||||
href="/seasons/{{ year }}/constructors">Constructors</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock navbar_extra %}
|
||||
|
||||
{% block body %}
|
||||
{% if statistic == "p10" %}{% include "season-p10.jinja" %}{% endif %}
|
||||
{% if statistic == "races" %}{% include "season-races.jinja" %}{% endif %}
|
||||
{% if statistic == "drivers" %}{% include "season-drivers.jinja" %}{% endif %}
|
||||
{% if statistic == "constructors" %}{% include "season-constructors.jinja" %}{% endif %}
|
||||
{% endblock body %}
|
||||
Reference in New Issue
Block a user