Ajoute 4 mécanismes moteur manquants pour le thème sécurité incendie : étiquette, carte, image SVG inline, bouton avec pièce jointe

Contenu et mécanisme uniquement, aucun style ajouté (voir consigne du
24/09/2026) : deux nouveaux kinds de contenu (badge/carte, rendu en
div brutes sans CSS), un mode SVG inline pour l'image (svg_markup,
nettoyé par un nouveau sanitizer allow-list avant chaque rendu) et un
fichier téléchargeable joignable à un bouton (upload/download routes,
stockage sous db.support_dir). Le futur système de templates portera
l'habillage visuel de ces éléments.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
william
2026-09-24 08:12:29 +02:00
co-authored by Claude Sonnet 5
parent e7c6ed7159
commit a34bcf4159
15 changed files with 668 additions and 18 deletions
@@ -0,0 +1,30 @@
import os
from flask import send_from_directory
from werkzeug.exceptions import NotFound
from werkzeug.wrappers import Response
import db
import document_engine
from core.flask_app import app
@app.route("/document/<slug>/elements/<int:element_id>/download-attachment")
def document_element_download_attachment(slug: str, element_id: int) -> Response:
"""Sert le fichier joint à un bouton (voir
document_element_upload_attachment.py) sous son nom d'origine
(`download_name`), jamais sous son nom de stockage anonymisé
(`attachment_stored_name`, un UUID)."""
element = document_engine.get_document_element(slug, element_id)
if element is None:
raise NotFound
stored_name = str(element["attributes"].get("attachment_stored_name", ""))
original_filename = str(element["attributes"].get("attachment_filename", ""))
if not stored_name:
raise NotFound
return send_from_directory(
os.path.join(db.support_dir(slug), "attachments"),
stored_name,
as_attachment=True,
download_name=original_filename or stored_name,
)