Portal data sync: avoid erasing emailperso

This commit is contained in:
viennet 2020-10-12 23:16:41 +02:00
parent a934542537
commit 9d859ad146
2 changed files with 18 additions and 14 deletions

View File

@ -340,8 +340,7 @@ def build_page(
def list_synch(context, sem, anneeapogee=None): def list_synch(context, sem, anneeapogee=None):
""" """"""
"""
inscrits = sco_inscr_passage.list_inscrits( inscrits = sco_inscr_passage.list_inscrits(
context, sem["formsemestre_id"], with_dems=True context, sem["formsemestre_id"], with_dems=True
) )
@ -573,8 +572,7 @@ def get_annee_naissance(ddmmyyyyy): # stokee en dd/mm/yyyy dans le XML portail
def do_import_etuds_from_portal(context, sem, a_importer, etudsapo_ident, REQUEST): def do_import_etuds_from_portal(context, sem, a_importer, etudsapo_ident, REQUEST):
"""Inscrit les etudiants Apogee dans ce semestre. """Inscrit les etudiants Apogee dans ce semestre."""
"""
log("do_import_etuds_from_portal: a_importer=%s" % a_importer) log("do_import_etuds_from_portal: a_importer=%s" % a_importer)
if not a_importer: if not a_importer:
return return
@ -777,6 +775,7 @@ def formsemestre_import_etud_admission(
unknowns = [] # etudiants avec NIP mais inconnus du portail unknowns = [] # etudiants avec NIP mais inconnus du portail
changed_mails = [] # modification d'adresse mails changed_mails = [] # modification d'adresse mails
cnx = context.GetDBConnexion() cnx = context.GetDBConnexion()
for i in ins: for i in ins:
etudid = i["etudid"] etudid = i["etudid"]
info = context.getEtudInfo(etudid=etudid, filled=1)[0] info = context.getEtudInfo(etudid=etudid, filled=1)[0]
@ -794,10 +793,13 @@ def formsemestre_import_etud_admission(
import_naissance=True, import_naissance=True,
import_identite=import_identite, import_identite=import_identite,
) )
apo_emailperso = etud.get("mailperso", "")
if info["emailperso"] and not apo_emailperso:
apo_emailperso = info["emailperso"]
if ( if (
import_email import_email
and info["email"] != etud["mail"] and info["email"] != etud["mail"]
or info["emailperso"] != etud.get("mailperso", "") or info["emailperso"] != apo_emailperso
): ):
scolars.adresse_edit( scolars.adresse_edit(
cnx, cnx,
@ -805,7 +807,7 @@ def formsemestre_import_etud_admission(
"etudid": etudid, "etudid": etudid,
"adresse_id": info["adresse_id"], "adresse_id": info["adresse_id"],
"email": etud["mail"], "email": etud["mail"],
"emailperso": etud.get("mailperso", ""), "emailperso": apo_emailperso,
}, },
context=context, context=context,
) )

View File

@ -268,8 +268,7 @@ def identite_list(cnx, *a, **kw):
def identite_edit_nocheck(cnx, args): def identite_edit_nocheck(cnx, args):
"""Modifie les champs mentionnes dans args, sans verification ni notification. """Modifie les champs mentionnes dans args, sans verification ni notification."""
"""
_identiteEditor.edit(cnx, args) _identiteEditor.edit(cnx, args)
@ -418,14 +417,17 @@ def notify_etud_change(context, email_addr, etud, before, after, subject):
txt = "\n".join(txt) txt = "\n".join(txt)
# build mail # build mail
log("notify_etud_change: sending notification to %s" % email_addr) log("notify_etud_change: sending notification to %s" % email_addr)
log("notify_etud_change: subject: %s" % subject)
log(txt)
msg = MIMEMultipart() msg = MIMEMultipart()
subj = Header("[ScoDoc] " + subject, SCO_ENCODING) subj = Header("[ScoDoc] " + subject, SCO_ENCODING)
msg["Subject"] = subj msg["Subject"] = subj
msg["From"] = context.get_preference("email_from_addr") msg["From"] = context.get_preference("email_from_addr")
msg["To"] = email_addr msg["To"] = email_addr
txt = MIMEText(txt, "plain", SCO_ENCODING) mime_txt = MIMEText(txt, "plain", SCO_ENCODING)
msg.attach(txt) msg.attach(mime_txt)
context.sendEmail(msg) context.sendEmail(msg)
return txt
# -------- # --------