copy icLibelleEntite in the output

This commit is contained in:
Benjamin Dauvergne 2016-05-19 16:41:08 +02:00
parent 96e6c0f463
commit 5c42e94035
1 changed files with 3 additions and 12 deletions

View File

@ -116,14 +116,6 @@ class CurieLdifParser(ldif.LDIFParser):
def handle_sun(self, dn, entry):
uid = self.assert_sv_attribute(entry, 'uid')
try:
ic_entite = self.assert_sv_attribute(entry, 'iclibelleentite')
except AssertionError:
ic_entite = None
else:
assert ic_entite in ('Recherche', 'Hopital', 'SI'), \
'valeur d\'ICEntite inconnue: %s' % ic_entite
supann_entite_affectation = ic_entite
if 'icprenomnaissance' in entry:
prenom = self.assert_sv_attribute(entry, 'icprenomnaissance')
else:
@ -138,7 +130,7 @@ class CurieLdifParser(ldif.LDIFParser):
cn = strip_accents('%s %s' % (prenom, nom)).strip()
telephone = entry.get('telephoneNumber', [])
mail = entry.get('mail', [])
if ic_entite == 'Recherche':
if entry.get('iclibelleentite', []) == ['Recherche']:
ic_equipe_recherche = self.assert_sv_attribute(entry, 'icequiperecherche')
ic_equipe_recherche_dn = ldap.dn.str2dn(ic_equipe_recherche)
assert ic_equipe_recherche_dn[0][0][0].lower() == 'ou', \
@ -148,17 +140,16 @@ class CurieLdifParser(ldif.LDIFParser):
else:
supann_entite_affectation_principale = None
d = {
'iclibelleentite': entry.get('iclibelleentite', []),
'uid': uid,
'sn': nom,
'givenName': prenom,
'cn': cn,
'mail': mail,
}
if supann_entite_affectation:
d['supannEntiteAffectation'] = supann_entite_affectation
if telephone:
d['telephoneNumber'] = telephone
if supann_entite_affectation:
if supann_entite_affectation_principale:
d['supannEntiteAffectationPrincipale'] = supann_entite_affectation_principale
self.users[uid].update(d)
self.users[uid].setdefault('_source', set()).add('sun')