forked from ScoDoc/ScoDoc
Capacité d'accueil: vérif. édition semestre, messages.
This commit is contained in:
parent
5edd7a8ba3
commit
3971145abd
@ -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(
|
||||
|
@ -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 = '<ul class="tf-msg"><li class="tf-msg">Code étape Apogée manquant</li></ul>'
|
||||
|
||||
# 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"""<ul class="tf-msg"><li class="tf-msg">Capacité d'accueil insuffisante
|
||||
(il y a {len(inscriptions)} inscrits non démissionaires)</li></ul>"""
|
||||
|
||||
if tf[0] == 0 or msg:
|
||||
return f"""<p>Formation <a class="discretelink" href="{
|
||||
url_for("notes.ue_table", scodoc_dept=g.scodoc_dept,
|
||||
|
@ -439,7 +439,7 @@ def formsemestre_inscription_with_modules(
|
||||
H.append("<ul>")
|
||||
for s in others:
|
||||
H.append(
|
||||
f"""<li><a href="{
|
||||
f"""<li><a class="stdlink" href="{
|
||||
url_for("notes.formsemestre_desinscription", scodoc_dept=g.scodoc_dept,
|
||||
formsemestre_id=s["formsemestre_id"], etudid=etudid )
|
||||
}" class="stdlink">désinscrire de {s["titreannee"]}
|
||||
@ -447,13 +447,13 @@ def formsemestre_inscription_with_modules(
|
||||
)
|
||||
H.append("</ul>")
|
||||
H.append(
|
||||
f"""<p><a href="{ url_for( "notes.formsemestre_inscription_with_modules",
|
||||
scodoc_dept=g.scodoc_dept, etudid=etudid, formsemestre_id=formsemestre_id,
|
||||
multiple_ok=1,
|
||||
group_ids=group_ids )
|
||||
f"""<p><a class="stdlink" href="{
|
||||
url_for( "notes.formsemestre_inscription_with_modules",
|
||||
scodoc_dept=g.scodoc_dept, etudid=etudid, formsemestre_id=formsemestre_id,
|
||||
multiple_ok=1,
|
||||
group_ids=group_ids )
|
||||
}">Continuer quand même l'inscription</a>
|
||||
</p>"""
|
||||
# was sco_groups.make_query_groups(group_ids)
|
||||
)
|
||||
return "\n".join(H) + footer
|
||||
#
|
||||
|
Loading…
Reference in New Issue
Block a user