From ab6202f37c2b8c9e7f206325e865ce03eea4e069 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre-Elliott=20B=C3=A9cue?= Date: Sat, 1 Dec 2012 14:28:52 +0100 Subject: [PATCH] [SOGo] On patche un peu partout pour pouvoir rendre le champ mail de ldap plus propre. Ignore-this: aed0fb0c7f88d3feb1f0be35b11780bf darcs-hash:20121201132852-b6762-f77d73b568bc1ad0fef3c9341cb2a00a34a09a0c.gz --- gestion/gen_confs/droits.py | 2 +- gestion/gest_crans.py | 7 ++++--- gestion/ldap_crans.py | 12 +++++++----- gestion/whos.py | 6 +++--- impression/print_status.py | 8 ++++++-- 5 files changed, 21 insertions(+), 14 deletions(-) diff --git a/gestion/gen_confs/droits.py b/gestion/gen_confs/droits.py index e19fc0f6..cf0c7e96 100644 --- a/gestion/gen_confs/droits.py +++ b/gestion/gen_confs/droits.py @@ -130,7 +130,7 @@ class droits_ldap(CransLdap, droits): mail = adher.mail().lower() if mail in mail_traite : continue mail_traite.append(mail) - if mail.find('@') == -1 : mail += '@crans.org' + if adher._data.get('uid', '') != '' and not mail.endswith('@crans.org') : mail += '@crans.org' if mail not in deja_inscrits.keys() : # Visiblement pas inscrit to_add.append([ mail, adher.Nom() ]) diff --git a/gestion/gest_crans.py b/gestion/gest_crans.py index 3d6ad33f..bc3bb025 100644 --- a/gestion/gest_crans.py +++ b/gestion/gest_crans.py @@ -421,7 +421,7 @@ def set_mail_ext(adher): Demande l'adresse mail extérieure d'un adhérent """ default = adher.mail() - if default.find('@') == -1: + if default.endswith('@crans.org'): # C'était une adresse crans default = '' @@ -663,7 +663,7 @@ def del_adher(adher): return quoi = u'Toutes les machines associées à cet adhérent seront détruites' - if adher.mail().find('@') == -1: + if adher._data.get('uid', '') != '': # L'adhérent a un compte machines = adher.machines() if not machines: @@ -1631,7 +1631,8 @@ def new_adher(adher): no, res = dialog(arg) if not no: mail = adher.mail() - if mail.find('@') == -1: mail += '@crans.org' + if adher._data.get('uid', '') != '' and not mail.endswith('@crans.org'): + mail += '@crans.org' adher.services_to_restart('ML_ens', [mail]) def modif_adher(adher): diff --git a/gestion/ldap_crans.py b/gestion/ldap_crans.py index a4e06340..687c7808 100644 --- a/gestion/ldap_crans.py +++ b/gestion/ldap_crans.py @@ -2113,7 +2113,11 @@ class Adherent(BaseProprietaire): def mail(self, new=None): if new == None: - return decode(self._data.get('mail', [''])[0]) + email = self._data.get('mail', [''])[0] + if not '@' in email: + return decode(email)+'@crans.org' + else: + return decode(email) new = validate_mail(new) @@ -2299,10 +2303,7 @@ class Adherent(BaseProprietaire): Si login = None, retourne le compte de l'adhérent """ if not login: - if self.mail().find('@') != -1: - return '' - else: - return self.mail() + return self._data.get('uid', [''])[0] # Supression des accents et espaces login = strip_accents(login) @@ -2343,6 +2344,7 @@ class Adherent(BaseProprietaire): # Lock du mail self.lock('mail', login) + # SOGO IS HUNGRY (modifier [login] en ["%s@crans.org"%(login)] quand tout sera ok) self._data['mail'] = [login] if not 'compte' in self.modifs: self.modifs.setdefault('compte', None) diff --git a/gestion/whos.py b/gestion/whos.py index 8fd6823b..b1885a7a 100644 --- a/gestion/whos.py +++ b/gestion/whos.py @@ -403,7 +403,7 @@ def adher_details(adher) : # Mail GL = RMH = u'' - if adher.mail().find(u'@')!=-1 or adher.mail() == '': + if adher.mail() == '' or adher.compte() == '': f += coul(u'Adresse mail : ','gras') if adher.mail() == '': f += coul('INCONNUE','rouge') @@ -415,9 +415,9 @@ def adher_details(adher) : else : f += coul(u'Login : ','gras') if adher.mail_invalide(): - f += coul(adher.mail(),'rouge') + f += coul(adher.compte(),'rouge') else: - f += adher.mail() + f += adher.compte() f += "\t" # controurneGreylisting if not adher.contourneGreylist(): diff --git a/impression/print_status.py b/impression/print_status.py index 59f53d1a..a2f8a7b8 100755 --- a/impression/print_status.py +++ b/impression/print_status.py @@ -146,11 +146,15 @@ for item in tasks_to_treat: if db_query['adherent']: target = db_query['adherent'][0] full_name = target.prenom() + u" " + target.nom() - send_to = [ target.mail() + u"@crans.org" ] + if not '@' in target.mail(): + mail = target.mail() + '@crans.org' + else: + mail = target.mail() + send_to = [ mail ] else: target = db_query['club'][0] full_name = u"Club " + target.nom() - send_to = map(lambda aid : db.search("aid=" + aid)['adherent'][0].mail() + u"@crans.org", target.imprimeurs()) + send_to = map(lambda aid : db.search("aid=" + aid)['adherent'][0].mail(), target.imprimeurs()) historique = target.historique() historique.reverse() # Ce qu'on cherche a des chances d'être récent et donc d'être à la fin de l'historique. file_dirname = files_directory + user + r"/"