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 import res_sem
from app.comp.res_compat import NotesTableCompat 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.etudiants import Identite
from app.models.groups import GroupDescr from app.models.groups import GroupDescr
import app.scodoc.sco_utils as scu import app.scodoc.sco_utils as scu
@ -317,10 +317,12 @@ def formsemestre_inscription_with_modules_form(etudid, only_ext=False):
"""Formulaire inscription de l'etud dans l'un des semestres existants. """Formulaire inscription de l'etud dans l'un des semestres existants.
Si only_ext, ne montre que les semestre extérieurs. 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 = [ H = [
html_sco_header.sco_header(), html_sco_header.sco_header(),
"<h2>Inscription de %s" % etud["nomprenom"], f"<h2>Inscription de {etud.nomprenom}",
] ]
if only_ext: if only_ext:
H.append(" dans un semestre extérieur") H.append(" dans un semestre extérieur")
@ -331,36 +333,47 @@ def formsemestre_inscription_with_modules_form(etudid, only_ext=False):
</p> </p>
<h3>Choisir un semestre:</h3>""" <h3>Choisir un semestre:</h3>"""
) )
F = html_sco_header.sco_footer() footer = html_sco_header.sco_footer()
sems = sco_formsemestre.do_formsemestre_list(args={"etat": "1"}) # sems = sco_formsemestre.do_formsemestre_list(args={"etat": "1"})
insem = do_formsemestre_inscription_list(args={"etudid": etudid, "etat": "I"}) formsemestres = (
if sems: 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>") H.append("<ul>")
for sem in sems: for formsemestre in formsemestres:
# Ne propose que les semestres ou etudid n'est pas déjà inscrit # Ne propose que les semestres où etudid n'est pas déjà inscrit
inscrit = False if formsemestre.id not in {
for i in insem: ins.formsemestre_id for ins in etud.inscriptions()
if i["formsemestre_id"] == sem["formsemestre_id"]: }:
inscrit = True if (not only_ext) or (formsemestre.modalite == "EXT"):
if not inscrit:
if (not only_ext) or (sem["modalite"] == "EXT"):
H.append( H.append(
""" f"""
<li><a class="stdlink" href="formsemestre_inscription_with_modules?etudid=%s&formsemestre_id=%s">%s</a> <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>") H.append("</ul>")
else: else:
H.append("<p>aucune session de formation !</p>") H.append("<p>aucune session de formation !</p>")
H.append( H.append(
'<h3>ou</h3> <a class="stdlink" href="%s">retour à la fiche de %s</a>' f"""<h3>ou</h3> <a class="stdlink" href="{
% ( url_for("scolar.ficheEtud", scodoc_dept=g.scodoc_dept, etudid=etudid)
url_for("scolar.ficheEtud", scodoc_dept=g.scodoc_dept, etudid=etudid), }">retour à la fiche de {etud.nomprenom}</a>"""
etud["nomprenom"],
)
) )
return "\n".join(H) + F return "\n".join(H) + footer
def formsemestre_inscription_with_modules( def formsemestre_inscription_with_modules(

View File

@ -208,10 +208,12 @@ def ficheEtud(etudid=None):
info["emaillink"] = "<em>(pas d'adresse e-mail)</em>" info["emaillink"] = "<em>(pas d'adresse e-mail)</em>"
# Champ dépendant des permissions: # Champ dépendant des permissions:
if authuser.has_permission(Permission.ScoEtudChangeAdr): if authuser.has_permission(Permission.ScoEtudChangeAdr):
info["modifadresse"] = ( info[
'<a class="stdlink" href="formChangeCoordonnees?etudid=%s">modifier adresse</a>' "modifadresse"
% etudid ] = f"""<a class="stdlink" href="{
) url_for("scolar.form_change_coordonnees",
scodoc_dept=g.scodoc_dept, etudid=etudid)
}">modifier adresse</a>"""
else: else:
info["modifadresse"] = "" info["modifadresse"] = ""
@ -235,7 +237,7 @@ def ficheEtud(etudid=None):
info["ne"], info["ne"],
show_date_inscr=False, show_date_inscr=False,
) )
grlink = '<span class="fontred">%s</span>' % descr["situation"] grlink = f"""<span class="fontred">{descr["situation"]}</span>"""
else: else:
e = {"etudid": etudid} e = {"etudid": etudid}
sco_groups.etud_add_group_infos( sco_groups.etud_add_group_infos(
@ -287,17 +289,20 @@ def ficheEtud(etudid=None):
info[ info[
"link_inscrire_ailleurs" "link_inscrire_ailleurs"
] = f"""<span class="link_bul_pdf"><a class="stdlink" href="{ ] = 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>""" }">inscrire à un autre semestre</a></span>"""
else: else:
info["link_inscrire_ailleurs"] = "" info["link_inscrire_ailleurs"] = ""
else: else:
# non inscrit # 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): if authuser.has_permission(Permission.ScoEtudInscrit):
l.append( l.append(
'<a href="%s/Notes/formsemestre_inscription_with_modules_form?etudid=%s">inscrire</a></li>' f"""<a href="{
% (scu.ScoURL(), etudid) url_for("notes.formsemestre_inscription_with_modules_form",
scodoc_dept=g.scodoc_dept, etudid=etudid)
}">inscrire</a></li>"""
) )
l.append("</b></b>") l.append("</b></b>")
info["liste_inscriptions"] = "\n".join(l) 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 @scodoc
@permission_required(Permission.ScoEtudChangeAdr) @permission_required(Permission.ScoEtudChangeAdr)
@scodoc7func @scodoc7func
def formChangeCoordonnees(etudid): def form_change_coordonnees(etudid):
"edit coordonnees etudiant" "edit coordonnees etudiant"
etud = Identite.query.get_or_404(etudid)
cnx = ndb.GetDBConnexion() cnx = ndb.GetDBConnexion()
etud = sco_etud.get_etud_info(filled=True, etudid=etudid)[0]
adrs = sco_etud.adresse_list(cnx, {"etudid": etudid}) adrs = sco_etud.adresse_list(cnx, {"etudid": etudid})
if adrs: if adrs:
adr = adrs[0] adr = adrs[0]
else: else:
adr = {} # no data for this student adr = {} # no data for this student
H = [ H = [
'<h2><font color="#FF0000">Changement des coordonnées de </font> %(nomprenom)s</h2><p>' f"""{html_sco_header.sco_header(
% etud 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( tf = TrivialFormulator(
request.base_url, request.base_url,
@ -799,7 +799,7 @@ def formChangeCoordonnees(etudid):
) )
dest_url = url_for("scolar.ficheEtud", scodoc_dept=g.scodoc_dept, etudid=etudid) dest_url = url_for("scolar.ficheEtud", scodoc_dept=g.scodoc_dept, etudid=etudid)
if tf[0] == 0: 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: elif tf[0] == -1:
return flask.redirect(dest_url) return flask.redirect(dest_url)
else: else: