Merge branch 'dev' into feature/73_compte_utilisateur

This commit is contained in:
Colin Maudry
2026-06-24 03:01:43 +02:00
76 changed files with 15560 additions and 1888 deletions
+27 -9
View File
@@ -2,6 +2,7 @@ import os
from shutil import rmtree
import dash_bootstrap_components as dbc
import pandas # noqa: F401 # eager import: avoid plotly's lazy-import race across Dash callback threads
import tomllib
from dash import (
Dash,
@@ -15,7 +16,7 @@ from dash import (
page_registry,
)
from dotenv import load_dotenv
from flask import Response
from flask import Flask, Response
from flask_login import current_user
from src.auth.setup import init_auth
@@ -38,12 +39,10 @@ META_TAGS = [
if DEVELOPMENT:
META_TAGS.append({"name": "robots", "content": "noindex"})
app: Dash = Dash(
title="decp.info",
use_pages=True,
compress=True,
meta_tags=META_TAGS,
)
# Le cache doit être initialisé AVANT la construction de Dash : `use_pages=True`
# importe les modules de pages pendant l'instanciation, et certains appellent des
# fonctions memoizées (@cache.memoize) dès l'import (ex. tableau.py).
server = Flask(__name__)
cache_dir = os.getenv("CACHE_DIR", "/tmp/decp-cache")
@@ -51,7 +50,7 @@ if os.path.exists(cache_dir):
rmtree(cache_dir)
cache.init_app(
app.server,
server,
config={
"CACHE_TYPE": "FileSystemCache",
"CACHE_DIR": cache_dir,
@@ -62,6 +61,14 @@ cache.init_app(
},
)
app: Dash = Dash(
server=server,
title="decp.info",
use_pages=True,
compress=True,
meta_tags=META_TAGS,
)
init_auth(app.server)
# Exempter les routes internes de Dash de la protection CSRF.
@@ -76,6 +83,10 @@ if _auth_csrf is not None:
if _vf is not None:
_auth_csrf.exempt(_vf)
from src.api import init_api # noqa: E402 # inline: src.db.conn must be ready first
init_api(app.server)
# robots.txt
@app.server.route("/robots.txt")
@@ -94,6 +105,7 @@ def sitemap():
"/observatoire",
"/tableau",
"/a-propos",
"/etapes",
]
xml = '<?xml version="1.0" encoding="UTF-8"?>\n'
xml += '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">\n'
@@ -170,7 +182,13 @@ navbar = dbc.Navbar(
style={"minWidth": "230px"},
),
dbc.Nav(
children=[dcc.Markdown(os.getenv("ANNOUNCEMENTS"), id="announcements")],
children=[
dcc.Markdown(
os.getenv("ANNOUNCEMENTS"),
id="announcements",
dangerously_allow_html=True,
),
],
style={
"maxWidth": "1200px",
"display": "inline-block",