From 3971145abda46cda83723d24cea6b97bc07eac67 Mon Sep 17 00:00:00 2001 From: ilona Date: Mon, 12 Aug 2024 14:40:35 +0200 Subject: [PATCH] =?UTF-8?q?Capacit=C3=A9=20d'accueil:=20v=C3=A9rif.=20?= =?UTF-8?q?=C3=A9dition=20semestre,=20messages.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/formsemestre.py | 10 ++++++++-- app/scodoc/sco_formsemestre_edit.py | 10 +++++++++- app/scodoc/sco_formsemestre_inscriptions.py | 12 ++++++------ 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/app/models/formsemestre.py b/app/models/formsemestre.py index 185e18a4f..34d34aad9 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 87cfadd00..f2b33b30e 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 #