Add error page
This commit is contained in:
@ -4,6 +4,8 @@ from flask_sqlalchemy import SQLAlchemy
|
|||||||
app: Flask = Flask(__name__)
|
app: Flask = Flask(__name__)
|
||||||
app.config['SQLALCHEMY_DATABASE_URI'] = "sqlite:///formula10.db"
|
app.config['SQLALCHEMY_DATABASE_URI'] = "sqlite:///formula10.db"
|
||||||
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
|
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
|
||||||
|
app.config['SESSION_TYPE'] = 'memcached'
|
||||||
|
app.config['SECRET_KEY'] = 'ich stinke nach maggi'
|
||||||
app.url_map.strict_slashes = False
|
app.url_map.strict_slashes = False
|
||||||
|
|
||||||
db: SQLAlchemy = SQLAlchemy()
|
db: SQLAlchemy = SQLAlchemy()
|
||||||
@ -12,8 +14,9 @@ db.init_app(app)
|
|||||||
# NOTE: These imports are required to register the routes. They need to be imported after "app" is declared
|
# NOTE: These imports are required to register the routes. They need to be imported after "app" is declared
|
||||||
import formula10.controller.race_controller # type: ignore
|
import formula10.controller.race_controller # type: ignore
|
||||||
import formula10.controller.season_controller
|
import formula10.controller.season_controller
|
||||||
import formula10.controller.admin_controller
|
|
||||||
import formula10.controller.rules_controller
|
import formula10.controller.rules_controller
|
||||||
|
import formula10.controller.admin_controller
|
||||||
|
import formula10.controller.error_controller
|
||||||
|
|
||||||
|
|
||||||
# TODO
|
# TODO
|
||||||
@ -21,10 +24,10 @@ import formula10.controller.rules_controller
|
|||||||
|
|
||||||
# Date stuff:
|
# Date stuff:
|
||||||
# - Date lock race guess entering + race result entering + season guess entering (frontend + backend)
|
# - Date lock race guess entering + race result entering + season guess entering (frontend + backend)
|
||||||
|
# - Some info popup that can be populated
|
||||||
# - Show timer until next race?
|
# - Show timer until next race?
|
||||||
|
|
||||||
# - Choose "place to guess" late before the race? Make a page for this?
|
# - Choose "place to guess" late before the race? Make a page for this?
|
||||||
# - Rules page
|
|
||||||
# - Store currently active user inside cookie
|
# - Store currently active user inside cookie
|
||||||
|
|
||||||
# - Make user order changeable using drag'n'drop?
|
# - Make user order changeable using drag'n'drop?
|
||||||
|
17
formula10/controller/error_controller.py
Normal file
17
formula10/controller/error_controller.py
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
from typing import cast
|
||||||
|
from flask import redirect, render_template, session
|
||||||
|
from werkzeug import Response
|
||||||
|
|
||||||
|
from formula10.frontend.template_model import TemplateModel
|
||||||
|
from formula10 import app
|
||||||
|
|
||||||
|
def error_redirect(error_message: str) -> Response:
|
||||||
|
session["error_message"] = error_message
|
||||||
|
return redirect(f"/error")
|
||||||
|
|
||||||
|
@app.route("/error")
|
||||||
|
def error_root() -> str:
|
||||||
|
model = TemplateModel(active_user_name=None, active_result_race_name=None)
|
||||||
|
message: str = cast(str, session["error_message"])
|
||||||
|
|
||||||
|
return render_template("error.jinja", model=model, error_message=message)
|
14
formula10/templates/error.jinja
Normal file
14
formula10/templates/error.jinja
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
{% extends 'base.jinja' %}
|
||||||
|
|
||||||
|
{% block title %}Formula 10 - Error{% endblock title %}
|
||||||
|
|
||||||
|
{% set active_page = "/error" %}
|
||||||
|
|
||||||
|
{% block body %}
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-body">
|
||||||
|
<h5 class="card-title text-danger fw-bold">Error</h5>
|
||||||
|
<h6 class="card-subtitle">{{ error_message }}</h6>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endblock body %}
|
Reference in New Issue
Block a user