diff --git a/app/models/formsemestre.py b/app/models/formsemestre.py index 185e18a4..34d34aad 100644 --- a/app/models/formsemestre.py +++ b/app/models/formsemestre.py @@ -1063,10 +1063,16 @@ class FormSemestre(models.ScoDocModel): return inscr if self.capacite_accueil is not None: - inscriptions = self.get_inscrits(etats={scu.INSCRIT, scu.DEMISSION}) + # tous sauf démissionnaires: + inscriptions = self.get_inscrits(etats={scu.INSCRIT, scu.DEF}) if len(inscriptions) >= self.capacite_accueil: raise ScoValueError( - f"Semestre {self.titre} complet: {len(self.inscriptions)} inscrits" + f"Semestre {self.titre} complet : {len(self.inscriptions)} inscrits", + dest_url=url_for( + "notes.formsemestre_status", + scodoc_dept=g.scodoc_dept, + formsemestre_id=self.id, + ), ) inscr = FormSemestreInscription( diff --git a/app/scodoc/sco_formsemestre_edit.py b/app/scodoc/sco_formsemestre_edit.py index 87cfadd0..f2b33b30 100644 --- a/app/scodoc/sco_formsemestre_edit.py +++ b/app/scodoc/sco_formsemestre_edit.py @@ -370,7 +370,7 @@ def do_formsemestre_createwithmodules(edit=False, formsemestre: FormSemestre = N { "title": "Capacité d'accueil", "size": 4, - "explanation": "laisser vide si pas de limite au nombre d'inscrits non démissionnaires", + "explanation": "nombre max d'inscrits (hors démissionnaires). Laisser vide si pas de limite.", "type": "int", "allow_null": True, }, @@ -858,6 +858,14 @@ def do_formsemestre_createwithmodules(edit=False, formsemestre: FormSemestre = N ): msg = '' + # check capacité accueil si indiquée + if edit and isinstance(tf[2]["capacite_accueil"], int): + new_capacite_accueil = tf[2]["capacite_accueil"] + inscriptions = formsemestre.get_inscrits(etats={scu.INSCRIT, scu.DEF}) + if len(inscriptions) > new_capacite_accueil: + msg = f"""""" + if tf[0] == 0 or msg: return f"""

Formation ") for s in others: H.append( - f"""

  • désinscrire de {s["titreannee"]} @@ -447,13 +447,13 @@ def formsemestre_inscription_with_modules( ) H.append("") H.append( - f"""

    Continuer quand même l'inscription

    """ - # was sco_groups.make_query_groups(group_ids) ) return "\n".join(H) + footer #