Compare commits

..

2 Commits

Author SHA1 Message Date
916847760c Update routes 2024-02-14 13:32:30 +01:00
ff0b70b380 Refactor nav-bar 2024-02-14 13:32:16 +01:00
3 changed files with 32 additions and 14 deletions

View File

@ -5,14 +5,25 @@ from database_utils import reload_static_data, export_dynamic_data
app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = "sqlite:///formula10.db";
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False;
app.config['SQLALCHEMY_DATABASE_URI'] = "sqlite:///formula10.db"
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
db.init_app(app)
@app.route("/")
def index():
return redirect("/raceguessresults")
@app.route("/reload")
def reload():
reload_static_data(db)
return redirect("/")
@app.route("/raceguessresults")
def raceguessresults():
users = User.query.all()
raceresults = RaceResult.query.all()
@ -22,13 +33,10 @@ def index():
for guess in Guess.query.all():
guesses[guess.race_id][guess.user_id] = guess
return render_template("index.jinja", users=users, raceresults=raceresults, guesses=guesses)
@app.route("/reload")
def reload():
reload_static_data(db)
return redirect("/")
return render_template("raceguessresults.jinja",
users=users,
raceresults=raceresults,
guesses=guesses)
# @app.route("/teams", methods=["GET", "POST"])

View File

@ -1,6 +1,11 @@
<!DOCTYPE html>
<html lang="en">
{# Easy nav-bar entries. When a page sets the active_page variable, the current entry will be underlined #}
{% macro nav_selector(page='', text='') %}
<a class="nav-link" href="/{{ page }}">{% if active_page == page %}<u>{% endif %} {{ text }} {% if active_page == page %}</u>{% endif %}</a>
{% endmacro %}
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
@ -15,25 +20,27 @@
</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>
Formula <i>10</i> - 2024
</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> #}
{{ nav_selector("raceguessresults", "Results for Races") }}
{{ nav_selector("seasonguessresults", "Results for Season") }}
{{ nav_selector("graphs", "Result Graphs") }}
{{ nav_selector("raceguesses", "Guess a Race") }}
{{ nav_selector("seasonguesses", "Guess the Season") }}
{{ nav_selector("rules", "Rules") }}
</div>
</div>
</div>
</nav>
{% block body %}{% endblock body %}
</body>
</html>

View File

@ -1,4 +1,7 @@
{% extends 'base.jinja' %}
{% set active_page = "raceguessresults" %}
{% block title %}Formula 10{% endblock title %}
{% block body %}