É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
+78
View File
@@ -108,6 +108,11 @@ export interface VolunteerRead {
wished_position_ids: string[];
/** Vœux : bénévoles avec qui il voudrait être affecté (0 à N, à sens unique). */
wished_companion_ids: string[];
/** Renseignés par le formulaire public d'inscription (voir schema forms). */
has_photo: boolean;
companion_wish_note: string | null;
self_declared_available: boolean;
willing_to_pay_fee: boolean;
created_at: string;
updated_at: string;
}
@@ -133,6 +138,9 @@ export interface VolunteerUpdate {
artist_ids?: string[] | null;
wished_position_ids?: string[] | null;
wished_companion_ids?: string[] | null;
companion_wish_note?: string | null;
self_declared_available?: boolean | null;
willing_to_pay_fee?: boolean | null;
}
/**
@@ -532,3 +540,73 @@ export interface PlanningNotificationResult {
skipped_no_email: number;
recipients: string[];
}
// --------------------------------------------------------------------------- //
// Formulaire public d'inscription //
// --------------------------------------------------------------------------- //
// Nom/prénom toujours collectés, pas dans cette liste (voir app/api/forms.py).
export type FormFieldType =
| 'EMAIL'
| 'PHONE'
| 'POSITION_WISHES'
| 'ARTIST_WISHES'
| 'COMPANION_WISH'
| 'AVAILABLE'
| 'WILLING_TO_PAY_FEE'
| 'PHOTO'
| 'COMMENT';
export interface FormFieldsSet {
fields: FormFieldType[];
}
export interface FormTemplateRead {
edition_id: string;
is_open: boolean;
fields: FormFieldType[];
}
export interface FormTemplateUpdate {
is_open: boolean;
}
export interface PublicPositionOption {
id: string;
name: string;
}
export interface PublicArtistOption {
id: string;
name: string;
performance_date: string;
}
/** Tout ce qu'il faut pour afficher le formulaire public — jamais plus. */
export interface PublicFormConfig {
is_open: boolean;
fields: FormFieldType[];
positions: PublicPositionOption[];
artists: PublicArtistOption[];
}
export interface FormSubmissionResult {
volunteer_id: string;
}
/** Champs du formulaire public — envoyés en `multipart/form-data` (photo
* possible). `position_wish_ids`/`artist_wish_ids` : JSON stringifié
* (`'["id1","id2"]'`), pas de tableau natif possible en multipart. */
export interface PublicFormSubmission {
first_name: string;
last_name: string;
hcaptcha_token: string;
email?: string;
phone?: string;
comment?: string;
companion_wish_note?: string;
available?: boolean;
willing_to_pay_fee?: boolean;
position_wish_ids?: string[];
artist_wish_ids?: string[];
photo?: File | null;
}