From 6c85740dd20ebf1d56bb9ffa24244f269129f1f1 Mon Sep 17 00:00:00 2001 From: Nicolas Dandrimont Date: Thu, 6 Oct 2011 15:31:57 +0200 Subject: [PATCH] =?UTF-8?q?[gest=5Fcrans,=20ldap=5Fcrans,=20whos]=20Robust?= =?UTF-8?q?esse=20si=20le=20responsable=20d'un=20club=20a=20=C3=A9t=C3=A9?= =?UTF-8?q?=20supprim=C3=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ignore-this: dbb616fe0cff5ba356ec8b2a0587f96c darcs-hash:20111006133157-ffbb2-9429c7756fb617b4e12babf3945d80333fe3f1af.gz --- gestion/gest_crans.py | 17 +++++++++++++---- gestion/ldap_crans.py | 10 +++++++--- gestion/whos.py | 5 ++++- 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/gestion/gest_crans.py b/gestion/gest_crans.py index 31b5f72e..973ade77 100644 --- a/gestion/gest_crans.py +++ b/gestion/gest_crans.py @@ -633,10 +633,19 @@ def set_droits(adher): map(lambda m: "%s$%s" % (adher.mail(), m), resultmls)) # On modifie ! - if not isadm: - adher.droits(result, light=True) - else: - adher.droits(result) + e = None + try: + if not isadm: + adher.droits(result, light=True) + else: + adher.droits(result) + except EnvironmentError, c: e = c.args[0] + except ValueError, c: e = c.args[0] + if e: + arg = u'--title "Modification des droits pour %s" ' % adher.Nom() + arg += u'--msgbox "%s\n\n\n" 0 0' % to_unicode(e) + dialog(arg) + return 1 def del_adher(adher): u""" diff --git a/gestion/ldap_crans.py b/gestion/ldap_crans.py index da7ae6ad..8b936dc8 100644 --- a/gestion/ldap_crans.py +++ b/gestion/ldap_crans.py @@ -2414,7 +2414,7 @@ class Adherent(BaseProprietaire): diff = [droit for droit in (ancien + new) if (droit not in ancien or droit not in new) and (droit in droits_critiques)] if len(diff) > 0: - raise("Droits critiques modifies (?) :: %s" % ','.join(diff)) + raise ValueError("Droits critiques modifies (?) :: %s" % ','.join(diff)) # Sauvegarde if new != self._data.get('droits', []): @@ -2531,8 +2531,12 @@ class Club(BaseProprietaire): if adher == None: aid = decode(self._data.get('responsable', [''])[0]) if aid: - return self.search('aid=%s' % aid)['adherent'][0] - else: return '' + l = self.search('aid=%s' % aid)['adherent'] + if l: + return l[0] + else: + raise ValueError("Responsable Invalide (%s)" % aid) + else: raise ValueError("Pas de responsable enregistré") if adher.__class__ != Adherent: raise ValueError diff --git a/gestion/whos.py b/gestion/whos.py index f3d7f8a1..4a6bef90 100644 --- a/gestion/whos.py +++ b/gestion/whos.py @@ -298,7 +298,10 @@ def clubs_brief(clubs) : else : machines = coul(nom,k) # Responsable - resp = c.responsable().Nom() + try: + resp = c.responsable().Nom() + except ValueError, e: + resp = e # Données data.append([c.id() , c.Nom(), c.local(), paid, resp, machines])