diff --git a/gestion/gest_crans.py b/gestion/gest_crans.py index 2a546693..c6db5a5c 100755 --- a/gestion/gest_crans.py +++ b/gestion/gest_crans.py @@ -33,7 +33,9 @@ from ldap_crans import adherent, machine, crans_ldap, crans, club, blacklist_ite def dialog(arg) : return affich_tools.dialog(u'Gestion des adhérents et machines du Crans',arg) -isimprimeur = u"Imprimeur" in crans_ldap().search("uid=%s" % script_utilisateur)['adherent'][0].droits() +droits = crans_ldap().search("uid=%s" % script_utilisateur)['adherent'][0].droits() +isimprimeur = u"Imprimeur" in droits +iscontroleur = u'Contrôleur' in droits ######################################################################### ## Fonctions de remplissage ou modification des paramètres d'un adhérent @@ -844,17 +846,39 @@ def set_admin(proprio) : if ann_scol+1 in proprio.paiement() : precab='on' else : precab='off' + txt = [] + if 'p' in proprio.controle(): + txt.append(u'Cotisation vérifiée') + paid_ok = 'on' + else: + paid_ok = 'off' + + if 'c' in proprio.controle(): + txt.append(u'Carte vérifiée') + carte_ok = 'on' + else: + carte_ok = 'off' + + if iscontroleur: txt = [] arg = u'--title "Etat administratif de %s" ' % proprio.Nom() arg+= u'--separate-output ' - arg+= u'--checklist "" 0 0 0 ' - if card and (proprio.etudes(0) != "ENS" or proprio.etudes(1) != "Pers"): - arg+= u'"1" "Carte d\'étudiant %d/%d fournie" "%s" ' % (ann_scol,ann_scol+1, carte) - elif card: - arg+= u'"1" "Preuve informelle d\'appartenance aux personnels de l\'ENS" "%s" ' % carte - arg+= u'"2" "Adhésion %d/%d réglée et charte signée" "%s" ' % (ann_scol,ann_scol+1,paid_now) + arg+= u'--checklist "%s" 0 0 0 ' % '\n'.join(txt) + + if carte_ok == 'off' or iscontroleur: + if card and (proprio.etudes(0) != "ENS" or proprio.etudes(1) != "Pers"): + arg+= u'"1" "Carte d\'étudiant %d/%d fournie" "%s" ' % (ann_scol,ann_scol+1, carte) + elif card: + arg+= u'"1" "Preuve informelle d\'appartenance aux personnels de l\'ENS" "%s" ' % carte + + if paid_ok == 'off' or iscontroleur: + arg+= u'"2" "Adhésion %d/%d réglée et charte signée" "%s" ' % (ann_scol,ann_scol+1,paid_now) if config.precab == 1 : arg+= u'"3" "Adhésion %d/%d réglée et charte signée (précâblage)" "%s" ' % (ann_scol+1,ann_scol+2,precab) - + + if iscontroleur: + arg += u'"4" "Vérification de la cotisation effectuée" "%s" ' % paid_ok + arg += u'"5" "Vérification de la carte d\'étudiant effectuée" "%s" ' % carte_ok + annul , result = dialog(arg) if annul : return 1 @@ -883,10 +907,17 @@ def set_admin(proprio) : return else: proprio.paiement(ann_scol) - elif '2\n' not in result : proprio.paiement(-ann_scol) + elif '2\n' not in result and (paid_ok == 'off' or iscontroleur): + proprio.paiement(-ann_scol) if '3\n' in result : proprio.paiement(ann_scol+1) - else : proprio.paiement(-ann_scol-1) + elif paid_ok == 'off' or iscontroleur: proprio.paiement(-ann_scol-1) + + if '4\n' in result: proprio.controle('+p') + elif iscontroleur: proprio.controle('-p') + + if '5\n' in result: proprio.controle('+c') + elif iscontroleur: proprio.controle('-c') ############################################################### ## Fonctions de remplissage ou modification des paramètres club diff --git a/gestion/ldap_crans.py b/gestion/ldap_crans.py index d4cb07f9..ed74f08f 100755 --- a/gestion/ldap_crans.py +++ b/gestion/ldap_crans.py @@ -63,7 +63,7 @@ blacklist_items = { u'bloq' : u'Bloquage total de tout services' , ################################################################################## ### Droits possibles -droits_possibles = [ u'Nounou', u'Apprenti', u'Modérateur', u'Câbleur', u'Déconnecteur', u'WebRadio' , u'Imprimeur', u'MultiMachines'] +droits_possibles = [ u'Nounou', u'Apprenti', u'Modérateur', u'Câbleur', u'Déconnecteur', u'WebRadio' , u'Imprimeur', u'MultiMachines', u'Contrôleur' ] ################################################################################## ### Variables internes diverses @@ -222,9 +222,9 @@ class crans_ldap: 'club': [ 'nom', 'chbre' ] } # Champs de recherche pour la recherche manuelle (en plus de la recherche auto) - non_auto_search_champs = { 'adherent': [ 'etudes', 'paiement', 'carteEtudiant', 'aid' , 'postalAddress', 'historique' ,'blacklist', 'droits', 'uidNumber', 'uid', 'info', 'solde' ], \ + non_auto_search_champs = { 'adherent': [ 'etudes', 'paiement', 'carteEtudiant', 'aid' , 'postalAddress', 'historique' ,'blacklist', 'droits', 'uidNumber', 'uid', 'info', 'solde' , 'controle' ], \ 'machine': [ 'mid' , 'ipsec', 'historique', 'blacklist' , 'puissance', 'canal', 'portTCPin', 'portTCPout', 'portUDPin', 'portUDPout', 'prise' , 'info', 'exempt' ] , - 'club': [ 'cid' , 'responsable', 'paiement', 'historique', 'blacklist', 'mailAlias', 'info'] } + 'club': [ 'cid' , 'responsable', 'paiement', 'historique', 'blacklist', 'mailAlias', 'info', 'controle' ] } # Scope des différentes recherches scope = { 'adherent': 1 , 'machine': 2 , 'club': 1 } @@ -1036,8 +1036,8 @@ class base_classes_crans(crans_ldap): def _set(self,champ,val): """ Met à jour les données de data et modifie modifs si besoin """ - if not self._data.has_key(champ) \ - or self._data.has_key(champ) and self._data[champ]!=val: + if (not self._data.has_key(champ) and val != []) \ + or (self._data.has_key(champ) and self._data[champ]!=val): self._data[champ]=val if champ not in self.modifs: self.modifs.append(champ) @@ -1187,6 +1187,30 @@ class base_proprietaire(base_classes_crans): self._set('solde',[str(new)]) return new + def controle(self,new=None): + """ + Controle du tresorier + New est de la forme {+-}{pc} + (p pour le paiement, c pour la carte + Retourne une chaine contenant p ou c ou les deux + """ + actuel = self._data.get('controle',[''])[0] + if new==None: + return actuel + + if not sre.match(r'^[+-][pc]$', new): + raise ValueError('modification de controle incorrecte') + + for c in 'pc': + if new == '+%s' % c and c not in actuel: + actuel += c + if new == '-%s' % c: + actuel = actuel.replace(c, '') + + if actuel == '': self._set('controle',[]) + else: self._set('controle',[actuel]) + return actuel + def paiement(self,action=None): """ Action est un entier représentant une année diff --git a/gestion/whos.py b/gestion/whos.py index f0e94070..20f6b132 100755 --- a/gestion/whos.py +++ b/gestion/whos.py @@ -109,16 +109,21 @@ def adhers_brief(adhers) : for a in adhers : ## Etat administratif ok = u'\x1b[1;32mo\x1b[1;0m' + ook = u'\x1b[1;32mO\x1b[1;0m' nok = u'\x1b[1;31mn\x1b[1;0m' # Paiement - if ann_scol in a.paiement() : paid = ok + if ann_scol in a.paiement(): + if 'p' in a.controle(): paid = ook + else: paid = ok else : paid = nok # Précablage if ann_scol+1 in a.paiement() : paid = coul(paid,'f_vert') # Carte d'étudiant - if ann_scol in a.carteEtudiant() : carte = ok + if ann_scol in a.carteEtudiant(): + if 'c' in a.controle(): carte = ook + else: carte = ok else : carte = nok machines = '' @@ -180,11 +185,14 @@ def clubs_brief(clubs) : for c in clubs : ## Etat administratif ok = u'\x1b[1;32mo\x1b[1;0m' + ook = u'\x1b[1;32mO\x1b[1;0m' nok = u'\x1b[1;31mn\x1b[1;0m' # Paiement - if ann_scol in c.paiement() : paid = ok + if ann_scol in c.paiement(): + if 'p' in c.controle(): paid = ook + else: paid = ok else : paid = nok - + # Précablage if ann_scol+1 in c.paiement() : paid = coul(paid,'f_vert') @@ -369,6 +377,7 @@ def adher_details(adher) : for an in adher.paiement() : g += u" %i-%i" % ( an, an+1 ) if len(g) > 35 : f += '\n\t' f += g + if 'p' in adher.controle(): f += coul(u' (OK)', 'vert') f += u'\n' # Cartes d'étudiant fournie @@ -381,6 +390,7 @@ def adher_details(adher) : for an in adher.carteEtudiant() : g += u" %i-%i" % ( an, an+1 ) if len(g) > 25 : f += '\n\t' f += g + if 'c' in adher.controle(): f += coul(u' (OK)', 'vert') f += u'\n' f += _blacklist(adher) @@ -565,6 +575,7 @@ def club_details(club) : for an in club.paiement() : g += " %i-%i" % ( an, an+1 ) if len(g) > 35 : f += '\n\t' f += g + if 'p' in club.controle(): f += coul(u' (OK)', 'vert') f += '\n' login = club.compte()