From 5ee9be467b1bf9fea5477b0167fb297e8899149f Mon Sep 17 00:00:00 2001 From: Youssef Date: Sun, 5 Jul 2026 12:47:46 +0200 Subject: [PATCH] feat: add new fields in pre-registration and sync with adherent and dotations --- .../com/astalange/core/entity/Adherent.java | 24 ++++++++++++ .../astalange/core/entity/PreInscription.java | 24 ++++++++++++ .../core/service/PreInscriptionService.java | 4 ++ .../V37__add_new_fields_pre_inscription.sql | 9 +++++ .../PublicInscriptionController.java | 37 ++++++++++++++++++- .../resources/templates/adherents/form.html | 30 +++++++++++++-- .../templates/public/formulaire.html | 35 ++++++++++++++++++ 7 files changed, 159 insertions(+), 4 deletions(-) create mode 100644 as-talange-core/src/main/resources/db/migration/V37__add_new_fields_pre_inscription.sql diff --git a/as-talange-core/src/main/java/com/astalange/core/entity/Adherent.java b/as-talange-core/src/main/java/com/astalange/core/entity/Adherent.java index 0f70569..3963d2e 100644 --- a/as-talange-core/src/main/java/com/astalange/core/entity/Adherent.java +++ b/as-talange-core/src/main/java/com/astalange/core/entity/Adherent.java @@ -50,6 +50,18 @@ public class Adherent { @Column(name = "ancienne_categorie", length = 50) private String ancienneCategorie; + @Column(name = "raison_changement_club") + private String raisonChangementClub; + + @Column(name = "comment_connu_club") + private String commentConnuClub; + + @Column(name = "taille_vetement", length = 50) + private String tailleVetement; + + @Column(length = 50) + private String pointure; + private boolean residentTalange = true; @Column(nullable = false, length = 10) @@ -105,6 +117,18 @@ public class Adherent { public String getAncienneCategorie() { return ancienneCategorie; } public void setAncienneCategorie(String ancienneCategorie) { this.ancienneCategorie = ancienneCategorie; } + public String getRaisonChangementClub() { return raisonChangementClub; } + public void setRaisonChangementClub(String raisonChangementClub) { this.raisonChangementClub = raisonChangementClub; } + + public String getCommentConnuClub() { return commentConnuClub; } + public void setCommentConnuClub(String commentConnuClub) { this.commentConnuClub = commentConnuClub; } + + public String getTailleVetement() { return tailleVetement; } + public void setTailleVetement(String tailleVetement) { this.tailleVetement = tailleVetement; } + + public String getPointure() { return pointure; } + public void setPointure(String pointure) { this.pointure = pointure; } + public boolean isResidentTalange() { return residentTalange; } public void setResidentTalange(boolean residentTalange) { this.residentTalange = residentTalange; } diff --git a/as-talange-core/src/main/java/com/astalange/core/entity/PreInscription.java b/as-talange-core/src/main/java/com/astalange/core/entity/PreInscription.java index 76f05ad..0250b15 100644 --- a/as-talange-core/src/main/java/com/astalange/core/entity/PreInscription.java +++ b/as-talange-core/src/main/java/com/astalange/core/entity/PreInscription.java @@ -64,6 +64,18 @@ public class PreInscription { @Column(name = "ancienne_categorie", length = 50) private String ancienneCategorie = "NA"; + @Column(name = "raison_changement_club") + private String raisonChangementClub; + + @Column(name = "comment_connu_club") + private String commentConnuClub; + + @Column(name = "taille_vetement", length = 50) + private String tailleVetement; + + @Column(length = 50) + private String pointure; + // Getters and Setters public Long getId() { return id; } public void setId(Long id) { this.id = id; } @@ -118,4 +130,16 @@ public class PreInscription { public String getAncienneCategorie() { return ancienneCategorie; } public void setAncienneCategorie(String ancienneCategorie) { this.ancienneCategorie = ancienneCategorie; } + + public String getRaisonChangementClub() { return raisonChangementClub; } + public void setRaisonChangementClub(String raisonChangementClub) { this.raisonChangementClub = raisonChangementClub; } + + public String getCommentConnuClub() { return commentConnuClub; } + public void setCommentConnuClub(String commentConnuClub) { this.commentConnuClub = commentConnuClub; } + + public String getTailleVetement() { return tailleVetement; } + public void setTailleVetement(String tailleVetement) { this.tailleVetement = tailleVetement; } + + public String getPointure() { return pointure; } + public void setPointure(String pointure) { this.pointure = pointure; } } diff --git a/as-talange-core/src/main/java/com/astalange/core/service/PreInscriptionService.java b/as-talange-core/src/main/java/com/astalange/core/service/PreInscriptionService.java index 95aea0a..c16fbbc 100644 --- a/as-talange-core/src/main/java/com/astalange/core/service/PreInscriptionService.java +++ b/as-talange-core/src/main/java/com/astalange/core/service/PreInscriptionService.java @@ -48,6 +48,10 @@ public class PreInscriptionService { adherent.setAncienClub(pre.getAncienClub()); adherent.setAncienneCategorie(pre.getAncienneCategorie()); adherent.setSexe(pre.getSexe()); + adherent.setRaisonChangementClub(pre.getRaisonChangementClub()); + adherent.setCommentConnuClub(pre.getCommentConnuClub()); + adherent.setTailleVetement(pre.getTailleVetement()); + adherent.setPointure(pre.getPointure()); // Par défaut adherent.setTypeMaillot("JOUEUR"); adherent.setResidentTalange(false); diff --git a/as-talange-core/src/main/resources/db/migration/V37__add_new_fields_pre_inscription.sql b/as-talange-core/src/main/resources/db/migration/V37__add_new_fields_pre_inscription.sql new file mode 100644 index 0000000..dd973b1 --- /dev/null +++ b/as-talange-core/src/main/resources/db/migration/V37__add_new_fields_pre_inscription.sql @@ -0,0 +1,9 @@ +ALTER TABLE pre_inscription ADD COLUMN raison_changement_club VARCHAR(255); +ALTER TABLE pre_inscription ADD COLUMN comment_connu_club VARCHAR(255); +ALTER TABLE pre_inscription ADD COLUMN taille_vetement VARCHAR(50); +ALTER TABLE pre_inscription ADD COLUMN pointure VARCHAR(50); + +ALTER TABLE adherent ADD COLUMN raison_changement_club VARCHAR(255); +ALTER TABLE adherent ADD COLUMN comment_connu_club VARCHAR(255); +ALTER TABLE adherent ADD COLUMN taille_vetement VARCHAR(50); +ALTER TABLE adherent ADD COLUMN pointure VARCHAR(50); diff --git a/as-talange-web/src/main/java/com/astalange/web/controller/PublicInscriptionController.java b/as-talange-web/src/main/java/com/astalange/web/controller/PublicInscriptionController.java index 52611d7..fc91976 100644 --- a/as-talange-web/src/main/java/com/astalange/web/controller/PublicInscriptionController.java +++ b/as-talange-web/src/main/java/com/astalange/web/controller/PublicInscriptionController.java @@ -7,7 +7,9 @@ import com.astalange.core.repository.PreInscriptionRepository; import com.astalange.core.repository.TokenPreInscriptionRepository; import com.astalange.core.repository.SaisonRepository; import com.astalange.core.repository.CategorieRepository; +import com.astalange.core.repository.EquipementRepository; import com.astalange.core.entity.Categorie; +import com.astalange.core.entity.Equipement; import com.astalange.core.service.CaptchaValidationService; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; @@ -20,6 +22,8 @@ import java.time.LocalDate; import java.util.UUID; import java.util.List; import java.math.BigDecimal; +import java.util.Set; +import java.util.TreeSet; @Controller @RequestMapping("/inscription-public") @@ -30,17 +34,20 @@ public class PublicInscriptionController { private final PreInscriptionRepository preInscriptionRepository; private final SaisonRepository saisonRepository; private final CategorieRepository categorieRepository; + private final EquipementRepository equipementRepository; public PublicInscriptionController(CaptchaValidationService captchaValidationService, TokenPreInscriptionRepository tokenRepository, PreInscriptionRepository preInscriptionRepository, SaisonRepository saisonRepository, - CategorieRepository categorieRepository) { + CategorieRepository categorieRepository, + EquipementRepository equipementRepository) { this.captchaValidationService = captchaValidationService; this.tokenRepository = tokenRepository; this.preInscriptionRepository = preInscriptionRepository; this.saisonRepository = saisonRepository; this.categorieRepository = categorieRepository; + this.equipementRepository = equipementRepository; } @Value("${captcha.sitekey:1x00000000000000000000AA}") @@ -97,6 +104,34 @@ public class PublicInscriptionController { model.addAttribute("preInscription", new PreInscription()); model.addAttribute("tokenUuid", tokenUuid); + + // Fetch tailles and pointures + List equipements = equipementRepository.findAll(); + Set tailles = new TreeSet<>(); + Set pointures = new TreeSet<>(); + for (Equipement eq : equipements) { + if (activeSaison.equals(eq.getSaison()) && eq.getTaillesDisponibles() != null && !eq.getTaillesDisponibles().trim().isEmpty()) { + String[] parts = eq.getTaillesDisponibles().split(","); + for (String p : parts) { + String val = p.trim(); + if (!val.isEmpty()) { + try { + int num = Integer.parseInt(val); + if (num >= 25 && num <= 50) { + pointures.add(val); + } else { + tailles.add(val); + } + } catch (NumberFormatException e) { + tailles.add(val); + } + } + } + } + } + model.addAttribute("taillesDisponibles", tailles); + model.addAttribute("pointuresDisponibles", pointures); + return "public/formulaire"; } diff --git a/as-talange-web/src/main/resources/templates/adherents/form.html b/as-talange-web/src/main/resources/templates/adherents/form.html index 142ce50..1602ec2 100644 --- a/as-talange-web/src/main/resources/templates/adherents/form.html +++ b/as-talange-web/src/main/resources/templates/adherents/form.html @@ -187,6 +187,30 @@ +
+ + +
+ + +
+
+ + +
+
+ + +
+
+ +
+ +
@@ -393,12 +417,12 @@ + th:selected="${(dot.taille != null and !dot.taille.isEmpty()) ? (dot.taille == #strings.trim(t)) : (#strings.trim(t) == adherent.tailleVetement or #strings.trim(t) == adherent.pointure)}"> -
+
- +
diff --git a/as-talange-web/src/main/resources/templates/public/formulaire.html b/as-talange-web/src/main/resources/templates/public/formulaire.html index 671db41..05f6df3 100644 --- a/as-talange-web/src/main/resources/templates/public/formulaire.html +++ b/as-talange-web/src/main/resources/templates/public/formulaire.html @@ -55,6 +55,11 @@
+ + +
+ + +
+
+ +
+ + +
+
@@ -221,21 +248,29 @@ const ancienClubInput = document.getElementById('ancienClub'); const ancienneCategorieBlock = document.getElementById('ancienneCategorieBlock'); const ancienneCategorieSelect = document.getElementById('ancienneCategorie'); + const raisonChangementClubBlock = document.getElementById('raisonChangementClubBlock'); + const raisonChangementClubInput = document.getElementById('raisonChangementClub'); if (ancienClubInput) { ancienClubInput.addEventListener('input', function() { if (this.value.trim().length > 0) { ancienneCategorieBlock.classList.remove('hidden'); ancienneCategorieSelect.required = true; + raisonChangementClubBlock.classList.remove('hidden'); + raisonChangementClubInput.required = true; } else { ancienneCategorieBlock.classList.add('hidden'); ancienneCategorieSelect.required = false; + raisonChangementClubBlock.classList.add('hidden'); + raisonChangementClubInput.required = false; } }); // Initial check if (ancienClubInput.value.trim().length > 0) { ancienneCategorieBlock.classList.remove('hidden'); ancienneCategorieSelect.required = true; + raisonChangementClubBlock.classList.remove('hidden'); + raisonChangementClubInput.required = true; } }