forked from ScoDoc/ScoDoc
small fixes
This commit is contained in:
parent
4b2e88c678
commit
034800ab9a
@ -445,10 +445,11 @@ class Identite(models.ScoDocModel):
|
||||
"prenom_etat_civil": self.prenom_etat_civil,
|
||||
}
|
||||
|
||||
def to_dict_scodoc7(self, restrict=False) -> dict:
|
||||
def to_dict_scodoc7(self, restrict=False, with_inscriptions=False) -> dict:
|
||||
"""Représentation dictionnaire,
|
||||
compatible ScoDoc7 mais sans infos admission.
|
||||
Si restrict, cache les infos "personnelles" si pas permission ViewEtudData
|
||||
Si with_inscriptions, inclut les champs "inscription"
|
||||
"""
|
||||
e_dict = self.__dict__.copy() # dict(self.__dict__)
|
||||
e_dict.pop("_sa_instance_state", None)
|
||||
@ -460,6 +461,8 @@ class Identite(models.ScoDocModel):
|
||||
adresse = self.adresses.first()
|
||||
if adresse:
|
||||
e_dict.update(adresse.to_dict(restrict=restrict))
|
||||
if with_inscriptions:
|
||||
e_dict.update(self.inscription_descr())
|
||||
return {k: v or "" for k, v in e_dict.items()} # convert_null_outputs_to_empty
|
||||
|
||||
def to_dict_bul(self, include_urls=True):
|
||||
@ -574,7 +577,9 @@ class Identite(models.ScoDocModel):
|
||||
return r[0] if r else None
|
||||
|
||||
def inscription_descr(self) -> dict:
|
||||
"""Description de l'état d'inscription"""
|
||||
"""Description de l'état d'inscription
|
||||
avec champs compatibles templates ScoDoc7
|
||||
"""
|
||||
inscription_courante = self.inscription_courante()
|
||||
if inscription_courante:
|
||||
titre_sem = inscription_courante.formsemestre.titre_mois()
|
||||
@ -585,7 +590,7 @@ class Identite(models.ScoDocModel):
|
||||
else:
|
||||
inscr_txt = "Inscrit en"
|
||||
|
||||
return {
|
||||
result = {
|
||||
"etat_in_cursem": inscription_courante.etat,
|
||||
"inscription_courante": inscription_courante,
|
||||
"inscription": titre_sem,
|
||||
@ -608,15 +613,20 @@ class Identite(models.ScoDocModel):
|
||||
inscription = "ancien"
|
||||
situation = "ancien élève"
|
||||
else:
|
||||
inscription = ("non inscrit",)
|
||||
inscription = "non inscrit"
|
||||
situation = inscription
|
||||
return {
|
||||
result = {
|
||||
"etat_in_cursem": "?",
|
||||
"inscription_courante": None,
|
||||
"inscription": inscription,
|
||||
"inscription_str": inscription,
|
||||
"situation": situation,
|
||||
}
|
||||
# aliases pour compat templates ScoDoc7
|
||||
result["etatincursem"] = result["etat_in_cursem"]
|
||||
result["inscriptionstr"] = result["inscription_str"]
|
||||
|
||||
return result
|
||||
|
||||
def inscription_etat(self, formsemestre_id: int) -> str:
|
||||
"""État de l'inscription de cet étudiant au semestre:
|
||||
@ -742,7 +752,6 @@ def check_etud_duplicate_code(args, code_name, edit=True):
|
||||
Raises ScoGenError si problème.
|
||||
"""
|
||||
etudid = args.get("etudid", None)
|
||||
assert (not edit) or (etudid is not None) # si edit, etudid doit être spécifié
|
||||
if not args.get(code_name, None):
|
||||
return
|
||||
etuds = Identite.query.filter_by(
|
||||
|
@ -271,7 +271,9 @@ def abs_notification_message(
|
||||
etud = Identite.get_etud(etudid)
|
||||
|
||||
# Variables accessibles dans les balises du template: %(nom_variable)s :
|
||||
values = sco_bulletins.make_context_dict(formsemestre, etud)
|
||||
values = sco_bulletins.make_context_dict(
|
||||
formsemestre, etud.to_dict_scodoc7(with_inscriptions=True)
|
||||
)
|
||||
|
||||
values["nbabs"] = nbabs
|
||||
values["nbabsjust"] = nbabsjust
|
||||
|
@ -735,17 +735,18 @@ def fill_etuds_info(etuds: list[dict], add_admission=True):
|
||||
etud["nomlycee"] = etud.get("nomlycee", "") or ""
|
||||
|
||||
|
||||
# voir Identite.inscription_descr et Identite.to_dict_scodoc7(with_inscriptions=True)
|
||||
def etud_inscriptions_infos(etudid: int, ne="") -> dict:
|
||||
"""Dict avec les informations sur les semestres passés et courant.
|
||||
{
|
||||
"sems" : , # trie les semestres par date de debut, le plus recent d'abord
|
||||
"ins" : ,
|
||||
"cursem" : ,
|
||||
"inscription" : ,
|
||||
"inscriptionstr" : ,
|
||||
"inscription_formsemestre_id" : ,
|
||||
"etatincursem" : ,
|
||||
"situation" : ,
|
||||
"inscription" : , # cursem["titremois"]
|
||||
"inscriptionstr" : , # "Inscrit en " + cursem["titremois"]
|
||||
"inscription_formsemestre_id" : , # cursem["formsemestre_id"]
|
||||
"etatincursem" : , # curi["etat"]
|
||||
"situation" : , # descr_situation_etud(etudid, ne)
|
||||
}
|
||||
"""
|
||||
from app.scodoc import sco_formsemestre
|
||||
|
Loading…
Reference in New Issue
Block a user