forked from ScoDoc/DocScoDoc
Accès infos admission via anciens codes
This commit is contained in:
parent
95d65f05a1
commit
0a4e4b89aa
@ -7,6 +7,7 @@
|
||||
from functools import cached_property
|
||||
from flask import abort, url_for
|
||||
from flask import g, request
|
||||
import sqlalchemy
|
||||
|
||||
from app import db
|
||||
from app import models
|
||||
@ -302,6 +303,24 @@ class Admission(db.Model):
|
||||
"Le bac. utiliser bac.abbrev() pour avoir une chaine de caractères."
|
||||
return Baccalaureat(self.bac, specialite=self.specialite)
|
||||
|
||||
def to_dict(self, no_nulls=False):
|
||||
"""Représentation dictionnaire,"""
|
||||
e = dict(self.__dict__)
|
||||
e.pop("_sa_instance_state", None)
|
||||
if no_nulls:
|
||||
for k in e:
|
||||
if e[k] is None:
|
||||
col_type = getattr(
|
||||
sqlalchemy.inspect(models.Admission).columns, "apb_groupe"
|
||||
).expression.type
|
||||
if isinstance(col_type, sqlalchemy.Text):
|
||||
e[k] = ""
|
||||
elif isinstance(col_type, sqlalchemy.Integer):
|
||||
e[k] = 0
|
||||
elif isinstance(col_type, sqlalchemy.Boolean):
|
||||
e[k] = False
|
||||
return e
|
||||
|
||||
|
||||
# Suivi scolarité / débouchés
|
||||
class ItemSuivi(db.Model):
|
||||
|
@ -38,6 +38,7 @@ from flask_mail import Message
|
||||
|
||||
from app import email
|
||||
from app import log
|
||||
from app.models import Admission
|
||||
from app.models.etudiants import make_etud_args
|
||||
import app.scodoc.sco_utils as scu
|
||||
import app.scodoc.notesdb as ndb
|
||||
@ -859,10 +860,12 @@ def list_scolog(etudid):
|
||||
return cursor.dictfetchall()
|
||||
|
||||
|
||||
def fill_etuds_info(etuds):
|
||||
def fill_etuds_info(etuds, add_admission=True):
|
||||
"""etuds est une liste d'etudiants (mappings)
|
||||
Pour chaque etudiant, ajoute ou formatte les champs
|
||||
-> informations pour fiche etudiant ou listes diverses
|
||||
|
||||
Si add_admission: ajoute au dict le schamps "admission" s'il n'y sont pas déjà.
|
||||
"""
|
||||
from app.scodoc import sco_formsemestre
|
||||
from app.scodoc import sco_formsemestre_inscriptions
|
||||
@ -872,6 +875,13 @@ def fill_etuds_info(etuds):
|
||||
for etud in etuds:
|
||||
etudid = etud["etudid"]
|
||||
etud["dept"] = g.scodoc_dept
|
||||
# Admission
|
||||
if add_admission and "nomlycee" not in etud:
|
||||
admission = (
|
||||
Admission.query.filter_by(etudid=etudid).first().to_dict(no_nulls=True)
|
||||
)
|
||||
etud.update(admission)
|
||||
#
|
||||
adrs = adresse_list(cnx, {"etudid": etudid})
|
||||
if not adrs:
|
||||
# certains "vieux" etudiants n'ont pas d'adresse
|
||||
@ -928,35 +938,35 @@ def fill_etuds_info(etuds):
|
||||
# XXXetud['partitions'] = {} # ne va pas chercher les groupes des anciens semestres
|
||||
etud["etatincursem"] = "?"
|
||||
|
||||
# nettoyage champs souvents vides
|
||||
if etud["nomlycee"]:
|
||||
# nettoyage champs souvent vides
|
||||
if etud.get("nomlycee"):
|
||||
etud["ilycee"] = "Lycée " + format_lycee(etud["nomlycee"])
|
||||
if etud["villelycee"]:
|
||||
etud["ilycee"] += " (%s)" % etud["villelycee"]
|
||||
etud["ilycee"] += " (%s)" % etud.get("villelycee", "")
|
||||
etud["ilycee"] += "<br/>"
|
||||
else:
|
||||
if etud["codelycee"]:
|
||||
if etud.get("codelycee"):
|
||||
etud["ilycee"] = format_lycee_from_code(etud["codelycee"])
|
||||
else:
|
||||
etud["ilycee"] = ""
|
||||
rap = ""
|
||||
if etud["rapporteur"] or etud["commentaire"]:
|
||||
if etud.get("rapporteur") or etud.get("commentaire"):
|
||||
rap = "Note du rapporteur"
|
||||
if etud["rapporteur"]:
|
||||
if etud.get("rapporteur"):
|
||||
rap += " (%s)" % etud["rapporteur"]
|
||||
rap += ": "
|
||||
if etud["commentaire"]:
|
||||
if etud.get("commentaire"):
|
||||
rap += "<em>%s</em>" % etud["commentaire"]
|
||||
etud["rap"] = rap
|
||||
|
||||
# if etud['boursier_prec']:
|
||||
# pass
|
||||
|
||||
if etud["telephone"]:
|
||||
if etud.get("telephone"):
|
||||
etud["telephonestr"] = "<b>Tél.:</b> " + format_telephone(etud["telephone"])
|
||||
else:
|
||||
etud["telephonestr"] = ""
|
||||
if etud["telephonemobile"]:
|
||||
if etud.get("telephonemobile"):
|
||||
etud["telephonemobilestr"] = "<b>Mobile:</b> " + format_telephone(
|
||||
etud["telephonemobile"]
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user