From 7a49298de594be48a753502078184308bafbb077 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre-Elliott=20B=C3=A9cue?= Date: Mon, 21 Oct 2013 19:33:52 +0200 Subject: [PATCH] =?UTF-8?q?[gest=5Fcrans]=20Possible=20de=20d=C3=A9sactive?= =?UTF-8?q?r=20un=20compte.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * En cas de corruption de mot de passe par exemple --- gestion/affich_tools.py | 1 + gestion/gest_crans.py | 38 +++++++++++++++++++++++++++++++++++--- gestion/ldap_crans.py | 13 +++++++++++++ 3 files changed, 49 insertions(+), 3 deletions(-) diff --git a/gestion/affich_tools.py b/gestion/affich_tools.py index e4aa0a9a..27bcdc9e 100755 --- a/gestion/affich_tools.py +++ b/gestion/affich_tools.py @@ -115,6 +115,7 @@ def to_unicode(txt, enc=encoding): return txt.decode("UTF-8") except: # Sinon c'est surement de l'iso + # donc on le décode en utf-8 \o/ return txt.decode("UTF-8") def to_encoding(txt, enc=encoding): diff --git a/gestion/gest_crans.py b/gestion/gest_crans.py index d10b91fa..8588d692 100755 --- a/gestion/gest_crans.py +++ b/gestion/gest_crans.py @@ -645,6 +645,35 @@ def set_droits(adher): dialog(arg) return 1 +def set_actif(adher): + u""" + Définition de l'état d'activité du compte. + """ + # Initialisation des différentes checkbox + inactif = on_off("0" in adher.active()) + + # Construction de la boîte de dialogue + texte = [] + checklist = [] + + if state: + checklist.append(u'"1" "Compte mail/serveur désactivé" "%s"' % (inactif)) + + # Il y a qqch de modifiable, on construit la checklist + arg = u'--title "Statut du compte %s" ' % adher.Nom() + arg += u'--separate-output ' + arg += u'--checklist "" 0 0 0 ' + arg += u' '.join(checklist) + + annul, result = dialog(arg) + if annul: return 1 + + # Traitement + if '1\n' in result: + adher.active(False) + else: + adher.active(True) + def del_adher(adher): u""" Destruction adhérent @@ -1664,9 +1693,7 @@ def modif_adher(adher): arg += u'"Administratif" "Précâblage, carte d\'étudiant, études" ' if not payant: arg += u'"Connexion" "Changer de type de connexion(gratuit->payant)" ' - if adher.compte(): changement_compte = u", compte sur zamok" - else: changement_compte = u"" - arg += u'"Etat-civil" "Nom, prénom%s" ' % changement_compte + arg += u'"Etat-civil" "Nom, prénom" ' if adher.chbre() == 'EXT': arg += u'"Adresse" "Déménagement" ' else: @@ -1681,6 +1708,8 @@ def modif_adher(adher): if isadm or isbureau: if 'cransAccount' in adher._data['objectClass']: arg += u'"Droits" "Modifier les droits alloués à cet adhérent" ' + if 'shadowAccount' in adher._data['objectClass']: + arg += u'"Etat" "Passer le compte à actif ou inactif" ' if 'posixAccount' in adher._data['objectClass']: arg += u'"Shell" "Changer le shell de cet utilisateur" ' if isdeconnecteur: @@ -1796,6 +1825,9 @@ def modif_adher(adher): elif res[0] == 'GPGFingerprint': __prompt_input_menu(adher.gpgFingerprint, 'GPG Fingerprint', u"Entrez ou modifier une empreinte GPG que l'adhérent possède (tout abus sera sanctionné).\nPour ajouter une empreinte modifier le dernier de la liste.") + elif res[0] == "Etat": + set_actif(adher) + elif res[0] == 'Shell': while 1: arg = u'--title "Nouveau shell pour %s" ' % adher.Nom() diff --git a/gestion/ldap_crans.py b/gestion/ldap_crans.py index f1cda62e..79d92340 100755 --- a/gestion/ldap_crans.py +++ b/gestion/ldap_crans.py @@ -2453,6 +2453,19 @@ class Adherent(BaseProprietaire): return decode(login) + def active(self, status=None): + """Permet d'activer ou désactiver un compte""" + if self.compte() == '': + raise EnvironmentError("Can't deactivate non-existing account") + if status == None: + return not (self._data.get("setExpire", [""])[0] == "0") + elif status == False: + self._set('setExpire', ["0"]) + else: + self._set('setExpire', []) + + return not (self._data.get("setExpire", [""])[0] == "0") + def canonical_alias(self, new=None): """ Retourne ou défini l'alias canonique""" if new == None: