Étape 21 : formulaire public d'inscription des bénévoles

Retire « constructeur de formulaire » des exclusions du CLAUDE.md (§ 5) —
décision explicite prise en conversation.

Un formulaire par édition (COORDINATION choisit les champs actifs parmi
neuf : email, téléphone, vœux de poste — max 2, vœux d'artiste — un par
soir de festival, vœu de compagnon en texte libre, disponibilité/
cotisation déclaratives, photo, commentaire ; nom/prénom toujours
collectés) ouvert/fermé à volonté, avec un lien à partager
(/inscription, aucun compte requis).

Backend : FormTemplate/FormField (migration 0013), quatre nouveaux champs
sur Volunteer (photo, companion_wish_note, self_declared_available,
willing_to_pay_fee), app/api/forms.py — les deux seuls endpoints publics
de toute l'API (GET .../form/public, POST .../form/public/submit),
protégés par hCaptcha (app/forms/captcha.py, désactivé sans
HCAPTCHA_SECRET_KEY) et un filet de sécurité global par édition
(form_submission_limiter). resolve_owned_ids/set_artists/
set_wished_positions déplacés vers app/api/_common.py, partagés avec
volunteers.py.

Frontend : écran de configuration (/inscriptions) avec lien copiable et
bascule ouvert/fermé, formulaire public (/inscription, hors RequireAuth)
avec widget hCaptcha chargé dynamiquement, capture photo native
(<input capture>), vœux de poste/artiste avec les mêmes règles que le
back-end. Réponses du formulaire visibles et éditables depuis la fiche
bénévole existante (ConfigVolunteers.tsx).

Vérifié : pytest (273 passés), ruff, alembic check, tsc --noEmit, eslint,
vite build, smoke (rendu SSR de chaque écran + flux de bout en bout du
formulaire en mode démonstration) — tous verts.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
AdamThomas
2026-09-21 20:24:32 +02:00
co-authored by Claude Sonnet 5
parent 55c5d539a8
commit 82088f3b0c
41 changed files with 2197 additions and 81 deletions
+47
View File
@@ -0,0 +1,47 @@
"""Vérification hCaptcha (module pur, pas de base) — voir `app/forms/captcha.py`."""
from app.config import get_settings
from app.forms.captcha import verify_hcaptcha
def test_verification_is_skipped_without_a_configured_secret(monkeypatch):
monkeypatch.delenv("HCAPTCHA_SECRET_KEY", raising=False)
get_settings.cache_clear()
assert verify_hcaptcha(None) is True
assert verify_hcaptcha("") is True
get_settings.cache_clear()
def test_empty_token_is_rejected_when_a_secret_is_configured(monkeypatch):
monkeypatch.setenv("HCAPTCHA_SECRET_KEY", "secret")
get_settings.cache_clear()
assert verify_hcaptcha(None) is False
assert verify_hcaptcha("") is False
get_settings.cache_clear()
def test_delegates_to_the_hcaptcha_api_when_a_secret_is_configured(monkeypatch):
monkeypatch.setenv("HCAPTCHA_SECRET_KEY", "secret")
get_settings.cache_clear()
calls = []
monkeypatch.setattr(
"app.forms.captcha._verify_with_hcaptcha",
lambda token, secret: calls.append((token, secret)) or True,
)
assert verify_hcaptcha("a-token") is True
assert calls == [("a-token", "secret")]
get_settings.cache_clear()
def test_network_failure_is_treated_as_a_failed_verification(monkeypatch):
monkeypatch.setenv("HCAPTCHA_SECRET_KEY", "secret")
get_settings.cache_clear()
def _raise(*args, **kwargs):
import httpx
raise httpx.ConnectError("boom")
monkeypatch.setattr("httpx.post", _raise)
assert verify_hcaptcha("a-token") is False
get_settings.cache_clear()