On proprifie un peu get_mail
This commit is contained in:
parent
c80c222805
commit
9498e06024
1 changed files with 22 additions and 6 deletions
28
objets.py
28
objets.py
|
@ -1132,16 +1132,32 @@ class proprio(CransLdapObject):
|
||||||
|
|
||||||
def get_mail(self):
|
def get_mail(self):
|
||||||
"""Renvoie un mail de contact valide, or None"""
|
"""Renvoie un mail de contact valide, or None"""
|
||||||
mails = ( self.get('canonicalAlias', []) or \
|
# On récupère les mails parmi les diverses possibilités.
|
||||||
self.get('mail', []) or \
|
mails = (
|
||||||
self.get('uid', []))
|
self.get('canonicalAlias', [])
|
||||||
if not mails or \
|
or self.get('mail', [])
|
||||||
any(b['type'] == 'mail_invalide' and b['fin'] == '-'
|
or self.get('mailExt', [])
|
||||||
for b in self.get('blacklist', []) ):
|
or self.get('uid', [])
|
||||||
|
)
|
||||||
|
|
||||||
|
# On vérifie si l'adhérent est en mail invalide
|
||||||
|
mail_invalide = any([
|
||||||
|
b['type'] == 'mail_invalide'
|
||||||
|
and b['fin'] == '-'
|
||||||
|
for b in self.get('blacklist', [])
|
||||||
|
])
|
||||||
|
|
||||||
|
# Si pas de mail ou mail invalide
|
||||||
|
if not mails or mail_invalide:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
# On récupère le premier de la liste.
|
||||||
mail = mails[0].value
|
mail = mails[0].value
|
||||||
|
|
||||||
|
# Login ? @crans.org
|
||||||
if '@' not in mail:
|
if '@' not in mail:
|
||||||
mail += '@crans.org'
|
mail += '@crans.org'
|
||||||
|
|
||||||
return mail
|
return mail
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue