1
0
forked from ScoDoc/ScoDoc

Améliore page inscription autre semestre

This commit is contained in:
Emmanuel Viennet 2022-09-27 12:21:19 +02:00
parent 47682e54d2
commit 8d607190ac
3 changed files with 61 additions and 43 deletions

View File

@ -34,7 +34,7 @@ from flask import flash, url_for, g, request
from app.comp import res_sem
from app.comp.res_compat import NotesTableCompat
from app.models import FormSemestre, FormSemestreInscription
from app.models import Formation, FormSemestre, FormSemestreInscription
from app.models.etudiants import Identite
from app.models.groups import GroupDescr
import app.scodoc.sco_utils as scu
@ -317,50 +317,63 @@ def formsemestre_inscription_with_modules_form(etudid, only_ext=False):
"""Formulaire inscription de l'etud dans l'un des semestres existants.
Si only_ext, ne montre que les semestre extérieurs.
"""
etud = sco_etud.get_etud_info(etudid=etudid, filled=True)[0]
etud: Identite = Identite.query.filter_by(
id=etudid, dept_id=g.scodoc_dept_id
).first_or_404()
H = [
html_sco_header.sco_header(),
"<h2>Inscription de %s" % etud["nomprenom"],
f"<h2>Inscription de {etud.nomprenom}",
]
if only_ext:
H.append(" dans un semestre extérieur")
H.append(
"""</h2>
<p class="help">L'étudiant sera inscrit à <em>tous</em> les modules du semestre
<p class="help">L'étudiant sera inscrit à <em>tous</em> les modules du semestre
choisi (sauf Sport &amp; Culture).
</p>
<h3>Choisir un semestre:</h3>"""
)
F = html_sco_header.sco_footer()
sems = sco_formsemestre.do_formsemestre_list(args={"etat": "1"})
insem = do_formsemestre_inscription_list(args={"etudid": etudid, "etat": "I"})
if sems:
footer = html_sco_header.sco_footer()
# sems = sco_formsemestre.do_formsemestre_list(args={"etat": "1"})
formsemestres = (
FormSemestre.query.filter_by(etat=True, dept_id=g.scodoc_dept_id)
.join(Formation)
.order_by(
Formation.acronyme,
FormSemestre.semestre_id,
FormSemestre.modalite,
FormSemestre.date_debut,
)
.all()
)
if len(formsemestres):
H.append("<ul>")
for sem in sems:
# Ne propose que les semestres ou etudid n'est pas déjà inscrit
inscrit = False
for i in insem:
if i["formsemestre_id"] == sem["formsemestre_id"]:
inscrit = True
if not inscrit:
if (not only_ext) or (sem["modalite"] == "EXT"):
for formsemestre in formsemestres:
# Ne propose que les semestres où etudid n'est pas déjà inscrit
if formsemestre.id not in {
ins.formsemestre_id for ins in etud.inscriptions()
}:
if (not only_ext) or (formsemestre.modalite == "EXT"):
H.append(
"""
<li><a class="stdlink" href="formsemestre_inscription_with_modules?etudid=%s&formsemestre_id=%s">%s</a>
f"""
<li>
<a class="stdlink" href="{
url_for("notes.formsemestre_inscription_with_modules",
scodoc_dept=g.scodoc_dept,
etudid=etudid, formsemestre_id=formsemestre.id
)}">{formsemestre.titre_mois()}</a>
</li>
"""
% (etudid, sem["formsemestre_id"], sem["titremois"])
)
H.append("</ul>")
else:
H.append("<p>aucune session de formation !</p>")
H.append(
'<h3>ou</h3> <a class="stdlink" href="%s">retour à la fiche de %s</a>'
% (
url_for("scolar.ficheEtud", scodoc_dept=g.scodoc_dept, etudid=etudid),
etud["nomprenom"],
)
f"""<h3>ou</h3> <a class="stdlink" href="{
url_for("scolar.ficheEtud", scodoc_dept=g.scodoc_dept, etudid=etudid)
}">retour à la fiche de {etud.nomprenom}</a>"""
)
return "\n".join(H) + F
return "\n".join(H) + footer
def formsemestre_inscription_with_modules(

View File

@ -208,10 +208,12 @@ def ficheEtud(etudid=None):
info["emaillink"] = "<em>(pas d'adresse e-mail)</em>"
# Champ dépendant des permissions:
if authuser.has_permission(Permission.ScoEtudChangeAdr):
info["modifadresse"] = (
'<a class="stdlink" href="formChangeCoordonnees?etudid=%s">modifier adresse</a>'
% etudid
)
info[
"modifadresse"
] = f"""<a class="stdlink" href="{
url_for("scolar.form_change_coordonnees",
scodoc_dept=g.scodoc_dept, etudid=etudid)
}">modifier adresse</a>"""
else:
info["modifadresse"] = ""
@ -235,7 +237,7 @@ def ficheEtud(etudid=None):
info["ne"],
show_date_inscr=False,
)
grlink = '<span class="fontred">%s</span>' % descr["situation"]
grlink = f"""<span class="fontred">{descr["situation"]}</span>"""
else:
e = {"etudid": etudid}
sco_groups.etud_add_group_infos(
@ -287,17 +289,20 @@ def ficheEtud(etudid=None):
info[
"link_inscrire_ailleurs"
] = f"""<span class="link_bul_pdf"><a class="stdlink" href="{
url_for("notes.formsemestre_inscription_with_modules_form", scodoc_dept=g.scodoc_dept, etudid=etudid)
url_for("notes.formsemestre_inscription_with_modules_form",
scodoc_dept=g.scodoc_dept, etudid=etudid)
}">inscrire à un autre semestre</a></span>"""
else:
info["link_inscrire_ailleurs"] = ""
else:
# non inscrit
l = ["<p><b>Etudiant%s non inscrit%s" % (info["ne"], info["ne"])]
l = [f"""<p><b>Étudiant{info["ne"]} non inscrit{info["ne"]}"""]
if authuser.has_permission(Permission.ScoEtudInscrit):
l.append(
'<a href="%s/Notes/formsemestre_inscription_with_modules_form?etudid=%s">inscrire</a></li>'
% (scu.ScoURL(), etudid)
f"""<a href="{
url_for("notes.formsemestre_inscription_with_modules_form",
scodoc_dept=g.scodoc_dept, etudid=etudid)
}">inscrire</a></li>"""
)
l.append("</b></b>")
info["liste_inscriptions"] = "\n".join(l)

View File

@ -740,26 +740,26 @@ def doSuppressAnnotation(etudid, annotation_id):
)
@bp.route("/formChangeCoordonnees", methods=["GET", "POST"])
@bp.route("/form_change_coordonnees", methods=["GET", "POST"])
@scodoc
@permission_required(Permission.ScoEtudChangeAdr)
@scodoc7func
def formChangeCoordonnees(etudid):
def form_change_coordonnees(etudid):
"edit coordonnees etudiant"
etud = Identite.query.get_or_404(etudid)
cnx = ndb.GetDBConnexion()
etud = sco_etud.get_etud_info(filled=True, etudid=etudid)[0]
adrs = sco_etud.adresse_list(cnx, {"etudid": etudid})
if adrs:
adr = adrs[0]
else:
adr = {} # no data for this student
H = [
'<h2><font color="#FF0000">Changement des coordonnées de </font> %(nomprenom)s</h2><p>'
% etud
f"""{html_sco_header.sco_header(
page_title=f"Changement coordonnées de {etud.nomprenom}"
)}
<h2>Changement des coordonnées de {etud.nomprenom}</h2>
<p>"""
]
header = html_sco_header.sco_header(
page_title="Changement adresse de %(nomprenom)s" % etud
)
tf = TrivialFormulator(
request.base_url,
@ -799,7 +799,7 @@ def formChangeCoordonnees(etudid):
)
dest_url = url_for("scolar.ficheEtud", scodoc_dept=g.scodoc_dept, etudid=etudid)
if tf[0] == 0:
return header + "\n".join(H) + tf[1] + html_sco_header.sco_footer()
return "\n".join(H) + tf[1] + html_sco_header.sco_footer()
elif tf[0] == -1:
return flask.redirect(dest_url)
else: