Patchs divers + mise jour de l'annuaire
darcs-hash:20040902051057-d1718-2e5bc8684bcff38b4e56318930da345f0b58f6b4.gz
This commit is contained in:
parent
1ec186d9dd
commit
a2411248dc
5 changed files with 128 additions and 76 deletions
|
@ -173,7 +173,7 @@ chbre_prises={ 'a' :
|
|||
'198':'217-', '199':'218-', '192':'219' , '239':'220' ,
|
||||
'245':'221' , '303':'222' , '305':'223' , '191':'224' ,
|
||||
'XXX':'225' , 'XXX':'226' , 'XXX':'227' , 'XXX':'228' ,
|
||||
'XXX':'229' , 'XXX':'230' , 'XXX':'231' , 'XXX':'232' ,
|
||||
'XXX':'229' , 'XXX':'230' , '129':'231-' , 'XXX':'232' ,
|
||||
'XXX':'233' , 'XXX':'234' , 'XXX':'235' , 'XXX':'236' ,
|
||||
'XXX':'237' , 'XXX':'238' , 'XXX':'239' , 'XXX':'240' ,
|
||||
'XXX':'241' , 'XXX':'242' , 'XXX':'243' , 'XXX':'244' ,
|
||||
|
|
|
@ -6,10 +6,10 @@
|
|||
############################################
|
||||
|
||||
#Précablage possible ?
|
||||
precab=1
|
||||
precab=0
|
||||
|
||||
#Bloquage si carte d'étudiant manquante pour l'année en cours
|
||||
carte_et=1
|
||||
carte_et=0
|
||||
|
||||
##Création de comptes
|
||||
# Gid des comptes créés
|
||||
|
|
|
@ -46,13 +46,13 @@ class switch(gen_config) :
|
|||
def gen_conf(self) :
|
||||
self.chbres.sort()
|
||||
for chbre in self.chbres :
|
||||
if chbre == '????' :
|
||||
continue
|
||||
bat = chbre[0].lower()
|
||||
a = self.db.search('chbre=%s' % chbre)['adherent']
|
||||
action = ''
|
||||
for adh in a :
|
||||
if ((ann_scol in adh.paiement() or
|
||||
((ann_scol-1) in adh.paiement and localtime()[1]==9)) and
|
||||
'bloq' not in adh.blacklist_actif()) :
|
||||
if (((ann_scol in adh.paiement()) or ((ann_scol-1) in adh.paiement and localtime()[1]==9)) and 'bloq' not in adh.blacklist_actif()) :
|
||||
# Il faut activer la prise
|
||||
anim('\tactivation chbre %s' % chbre)
|
||||
action = 'enable'
|
||||
|
@ -67,7 +67,7 @@ class switch(gen_config) :
|
|||
# Action sur le switch
|
||||
prise = chbre_prises[bat][chbre[1:].lower()]
|
||||
sw=hp(bat,int(prise[0]))
|
||||
r = sw.set_prise(int(prise[1:4]),'disable')
|
||||
r = sw.set_prise(int(prise[1:4]),action)
|
||||
sw.close()
|
||||
if not r :
|
||||
raise RuntimeError('Erreur de communiquation')
|
||||
|
|
|
@ -64,10 +64,8 @@ def set_bases(adher) :
|
|||
|
||||
try : adher.tel(result[2])
|
||||
except ValueError, c : err += c.args[0] + '\n'
|
||||
|
||||
try : c = adher.chbre(result[3])
|
||||
except ValueError, c : err += c.args[0] + '\n'
|
||||
except EnvironmentError, c : err += c.args[0] + '\n'
|
||||
|
||||
err += _set_chbre(adher,result[3])
|
||||
|
||||
# Des erreurs ?
|
||||
if err :
|
||||
|
@ -77,12 +75,39 @@ def set_bases(adher) :
|
|||
# On redemande
|
||||
return set_bases(adher)
|
||||
|
||||
if c =='EXT' :
|
||||
if adher.chbre() =='EXT' :
|
||||
# Il faut demander l'adresse extérieure
|
||||
if set_addr_ext(adher) :
|
||||
# Annulation
|
||||
return set_bases(adher)
|
||||
|
||||
|
||||
def _set_chbre(adher,chbre) :
|
||||
""" Attribution de la chambre chbre à l'adhérent fourni
|
||||
Retourne une chaine (unicode) avec l'erreur éventuelle
|
||||
"""
|
||||
if chbre=='????' :
|
||||
# Réservé à un usage interne
|
||||
return u'Chambre invalide\n'
|
||||
|
||||
try : c = adher.chbre(chbre)
|
||||
except EnvironmentError, c : return c.args[0] + '\n'
|
||||
except ValueError, c :
|
||||
try :
|
||||
squatteur = c.args[1]
|
||||
aff(squatteur)
|
||||
arg = u'--title "Inscription adhérent" '
|
||||
arg+= u'--yesno "Un adhérent (%s) occupe déjà cette chambre.\n' % squatteur.Nom()
|
||||
arg+= u'\nChanger la chambre de cet adhérent ?" 0 0'
|
||||
no, res = dialog(arg)
|
||||
if no : raise # On laisse l'erreur
|
||||
squatteur.chbre('????')
|
||||
squatteur.save()
|
||||
return _set_chbre(adher,chbre) # On recommence, le géneur doit être parti.
|
||||
except :
|
||||
return c.args[0] + '\n'
|
||||
|
||||
return u''
|
||||
|
||||
def set_addr_ext(adher) :
|
||||
""" Définition de l'adresse extérieure d'un adhérent
|
||||
La chambre de cet adhérent doit être EXT, sinon erreur """
|
||||
|
@ -359,15 +384,17 @@ def set_compte(adher) :
|
|||
# Première tentative
|
||||
err = 0
|
||||
try : login = adher.compte(login)
|
||||
except EnvironmentError, c : err = 1 # Locké
|
||||
except ValueError, c :
|
||||
try :
|
||||
c.arg[1]
|
||||
c.args[1]
|
||||
# Le compte existe => 2ème tentative (1ere lettre prénom + nom)
|
||||
login = adher.prenom()[0]+login
|
||||
login = login.lower()
|
||||
err =2
|
||||
except : err = 1
|
||||
|
||||
except :
|
||||
err = 1
|
||||
except EnvironmentError, c : err = 1 # Locké
|
||||
|
||||
if err :
|
||||
while 1:
|
||||
# Mauvais login => on demande
|
||||
|
@ -657,7 +684,7 @@ def set_admin(proprio) :
|
|||
if card :
|
||||
arg+= u'"1" "Carte d\'étudiant %d/%d fournie" "%s" ' % (ann_scol,ann_scol+1, carte)
|
||||
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 :
|
||||
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)
|
||||
|
||||
annul , result = dialog(arg)
|
||||
|
@ -950,26 +977,33 @@ def modif_adher(adher) :
|
|||
"""
|
||||
Modification de l'adhérent fourni (instance de adhérent)
|
||||
Retourne 1 si annulation.
|
||||
"""
|
||||
arg = u'--title "Modification de %s" ' % adher.Nom()
|
||||
arg+= u'--menu "Que souhaitez vous modifier ?" 0 0 0 '
|
||||
arg+= u'"Admistratif" "Précâblage, carte d\'étudiant, études" '
|
||||
if adher.chbre() == 'EXT' :
|
||||
arg+= u'"Adresse" "Déménagement" '
|
||||
"""
|
||||
# Préliminaire : si la chambre est inconnue on force la question
|
||||
if adher.chbre() =='????' :
|
||||
res=['Chambre']
|
||||
arg = u'--title "Modification de %s" ' % adher.Nom()
|
||||
arg+= u'--msgbox "ERREUR : la chambre de cet adhérent est inconnue !\n\n\n" 0 0'
|
||||
dialog(arg)
|
||||
else :
|
||||
arg+= u'"Chambre" "Déménagement" '
|
||||
arg+= u'"Etudes" "Changement d\'année ou de filière" '
|
||||
arg+= u'"Téléphone" "Changement de numéro de téléphone" '
|
||||
arg+= u'"Mail" "Créer un compte ou changer l\'adresse mail de contact" '
|
||||
arg+= u'"Alias" "Créer ou supprimer un alias mail" '
|
||||
arg+= u'"Remarque" "Ajouter ou modifer un commentaire" '
|
||||
if isadm :
|
||||
arg+= u'"Droits" "Modifier les droits alloués à cet adhérent" '
|
||||
if isdeconnecteur :
|
||||
arg+= u'"Blackliste" "Modifier la blackliste de cet adhérent" '
|
||||
annul, res = dialog(arg)
|
||||
arg = u'--title "Modification de %s" ' % adher.Nom()
|
||||
arg+= u'--menu "Que souhaitez vous modifier ?" 0 0 0 '
|
||||
arg+= u'"Admistratif" "Précâblage, carte d\'étudiant, études" '
|
||||
if adher.chbre() == 'EXT' :
|
||||
arg+= u'"Adresse" "Déménagement" '
|
||||
else :
|
||||
arg+= u'"Chambre" "Déménagement" '
|
||||
arg+= u'"Etudes" "Changement d\'année ou de filière" '
|
||||
arg+= u'"Téléphone" "Changement de numéro de téléphone" '
|
||||
arg+= u'"Mail" "Créer un compte ou changer l\'adresse mail de contact" '
|
||||
arg+= u'"Alias" "Créer ou supprimer un alias mail" '
|
||||
arg+= u'"Remarque" "Ajouter ou modifer un commentaire" '
|
||||
if isadm :
|
||||
arg+= u'"Droits" "Modifier les droits alloués à cet adhérent" '
|
||||
if isdeconnecteur :
|
||||
arg+= u'"Blackliste" "Modifier la blackliste de cet adhérent" '
|
||||
annul, res = dialog(arg)
|
||||
|
||||
if annul : return 1
|
||||
if annul : return 1
|
||||
|
||||
if res[0]=='Etudes' :
|
||||
set_etudes(adher)
|
||||
|
@ -993,21 +1027,18 @@ def modif_adher(adher) :
|
|||
annul,res = dialog(arg)
|
||||
if annul : return 1
|
||||
|
||||
e=0
|
||||
try :
|
||||
c = adher.chbre(res[0])
|
||||
if c =='EXT' :
|
||||
e = _set_chbre(adher,res[0])
|
||||
if e :
|
||||
arg = u'--title "Déménagement de la %s" ' % adher.chbre()
|
||||
arg+= u'--msgbox "%s\n\n\n" 0 0' % e
|
||||
dialog(arg)
|
||||
else :
|
||||
if adher.chbre() =='EXT' :
|
||||
# Il faut demander l'adresse extérieure
|
||||
if set_addr_ext(adher) :
|
||||
# Annulation
|
||||
continue
|
||||
break
|
||||
except EnvironmentError, c : e = c.args[0]
|
||||
except ValueError, c : e = c.args[0]
|
||||
if e :
|
||||
arg = u'--title "Déménagement de la %s" ' % adher.chbre()
|
||||
arg+= u'--msgbox "%s\n\n\n" 0 0' % e
|
||||
dialog(arg)
|
||||
elif res[0]=='Adresse' :
|
||||
arg = u'--title "Déménagement de %s" ' % adher.Nom()
|
||||
arg+= u'--menu "Question :" 0 0 0 '
|
||||
|
@ -1409,15 +1440,16 @@ def menu_principal() :
|
|||
annul , result = dialog(arg)
|
||||
if annul : continue
|
||||
choix=result[0]
|
||||
if choix=='Fixe' :
|
||||
try : becane = machine(proprio,'fixe')
|
||||
except ValueError, c:
|
||||
arg = '--title "Nouvelle machine" '
|
||||
arg += '--msgbox "%s\n\n\n" 0 0' % c.args[0]
|
||||
dialog(arg)
|
||||
continue
|
||||
elif choix=='Wifi' :
|
||||
becane = machine(proprio,'wifi')
|
||||
try :
|
||||
if choix=='Fixe' :
|
||||
becane = machine(proprio,'fixe')
|
||||
elif choix=='Wifi' :
|
||||
becane = machine(proprio,'wifi')
|
||||
except ValueError, c:
|
||||
arg = '--title "Nouvelle machine" '
|
||||
arg += '--msgbox "%s\n\n\n" 0 0' % c.args[0]
|
||||
dialog(arg)
|
||||
continue
|
||||
if set_machine(becane) :
|
||||
# Annulation
|
||||
del(becane) ; becane = None
|
||||
|
@ -1434,7 +1466,13 @@ def menu_principal() :
|
|||
|
||||
elif choix=='mMc' :
|
||||
# Modif machine courante
|
||||
if set_machine(becane) :
|
||||
if not proprio :
|
||||
proprio = becane.proprietaire()
|
||||
if proprio.chbre() == '????' :
|
||||
arg = u'--title "Ajout d\'une machine" '
|
||||
arg+= u'--msgbox "ERREUR : la chambre de %s est inconnue !\n\n\n" 0 0' % proprio.Nom()
|
||||
dialog(arg)
|
||||
elif set_machine(becane) :
|
||||
# Annulation des modifs
|
||||
becane.restore()
|
||||
|
||||
|
|
|
@ -312,8 +312,12 @@ class crans_ldap :
|
|||
args=map(tr,args)
|
||||
|
||||
if new in serv.keys() :
|
||||
if args not in serv[new] :
|
||||
modlist = ldap.modlist.modifyModlist({ 'args' : serv[new] }, { 'args' : serv[new] + args })
|
||||
new_args = []
|
||||
for arg in args :
|
||||
if arg not in serv[new] :
|
||||
new_args.append(arg)
|
||||
if new_args :
|
||||
modlist = ldap.modlist.modifyModlist({ 'args' : serv[new] }, { 'args' : serv[new] + new_args })
|
||||
self.conn.modify_s(serv_dn,modlist)
|
||||
# else rien à faire
|
||||
else :
|
||||
|
@ -931,14 +935,14 @@ class base_proprietaire(base_classes_crans) :
|
|||
if m.ipsec() and not 'conf_wifi' in serv :
|
||||
self.services_to_restart('conf_wifi')
|
||||
elif not self.chbre() in serv :
|
||||
self.services_to_restart('chbre',[self.chbre()])
|
||||
self.services_to_restart('switch',[self.chbre()])
|
||||
if self.machines() :
|
||||
for s in ['dhcp', 'dns', 'firewall' ] :
|
||||
if s not in serv :
|
||||
serv.append(s)
|
||||
|
||||
# Vérification si changement de bât, ce qui obligerai un changement d'IP
|
||||
if 'chbre' in self.modifs :
|
||||
if 'chbre' in self.modifs and self.chbre()!='????' :
|
||||
# Verif si machines avec bonnes ip
|
||||
err = 0
|
||||
for m in self.machines() :
|
||||
|
@ -956,10 +960,7 @@ class base_proprietaire(base_classes_crans) :
|
|||
ret += "\nChangement d'IP machine %s : " % m.nom()
|
||||
try :
|
||||
ret += "%s -> %s" % ( ip, m.ip('<automatique>') )
|
||||
se, r = m.save()
|
||||
for s in se :
|
||||
if s not in serv :
|
||||
serv.append(s)
|
||||
r = m.save()
|
||||
except c :
|
||||
ret += coul(u'ERREUR : %s' % c.args[0], rouge)
|
||||
err = 1
|
||||
|
@ -1093,6 +1094,10 @@ class adherent(base_proprietaire) :
|
|||
|
||||
self._set('chbre',['EXT'])
|
||||
return 'EXT'
|
||||
elif new.upper() == '????' :
|
||||
# On ne sait pas ou est l'adhérent
|
||||
self._set('chbre',['????'])
|
||||
return '????'
|
||||
|
||||
new = new.capitalize()
|
||||
bat = new[0].lower()
|
||||
|
@ -1102,7 +1107,7 @@ class adherent(base_proprietaire) :
|
|||
chbres = annuaires.chbre_prises[bat].keys()
|
||||
if new[1:] not in chbres or len(new)<4 or not new[1:4].isdigit() :
|
||||
chbres.sort()
|
||||
aide = u"Chambre inconnue dans le bâtiment, les chambres valides sont :"
|
||||
aide = u"Chambre inconnue dans le batiment, les chambres valides sont :"
|
||||
a=0
|
||||
for c in chbres :
|
||||
if len(c)>=3 and not c[:3].isdigit() :
|
||||
|
@ -1120,8 +1125,16 @@ class adherent(base_proprietaire) :
|
|||
raise ValueError(u'Bâtiment inconnu.')
|
||||
|
||||
# La chambre est valide, est-elle déja occupée ?
|
||||
if self.exist('chbre=%s' % new) :
|
||||
raise ValueError(u'Chambre déjà occupée.')
|
||||
test = self.exist('chbre=%s' % new)
|
||||
if test :
|
||||
search = test[0].split(',')[0]
|
||||
if search.split('=')[0]!='aid' :
|
||||
raise ValueError(u'Chambre déjà occupée.')
|
||||
adh = self.search(search,self._modifiable)['adherent']
|
||||
if len(adh) != 1 :
|
||||
raise ValueError(u'Chambre déjà occupée.')
|
||||
else :
|
||||
raise ValueError(u'Chambre déjà occupée.',adh[0])
|
||||
|
||||
# Lock de la chambre
|
||||
self._locks.append(self.lock('chbre',new))
|
||||
|
@ -1279,10 +1292,13 @@ class adherent(base_proprietaire) :
|
|||
if login[0]=='-' :
|
||||
raise ValueError(u"- interdit en première position.")
|
||||
|
||||
|
||||
if mailexist(login) :
|
||||
raise ValueError(u"Login existant ou correspondant à un alias mail.",1)
|
||||
|
||||
|
||||
home = '/home/' + login
|
||||
if os.path.exists(home) :
|
||||
raise ValueError(u'Création du compte impossible : home existant',1)
|
||||
|
||||
# Lock du mail
|
||||
self._locks.append(self.lock('mail',login))
|
||||
|
||||
|
@ -1321,10 +1337,6 @@ class adherent(base_proprietaire) :
|
|||
self._data['uidNumber']= [ str(uidNumber) ]
|
||||
self._data['gidNumber']=[ str(config.gid) ]
|
||||
|
||||
home = '/home/' + login
|
||||
if os.path.exists(home) :
|
||||
raise RuntimeError(u'Création du compte impossible : home existant')
|
||||
|
||||
self._data['homeDirectory']=[ preattr(home)[1] ]
|
||||
self._data['gecos'] = [ preattr(self.Nom())[1] + ',,,' ]
|
||||
|
||||
|
@ -1535,9 +1547,13 @@ class machine(base_classes_crans) :
|
|||
self.__typ = typ
|
||||
self._modifiable = 'w'
|
||||
|
||||
if self.__proprietaire.chbre() == 'EXT' and typ == 'fixe' :
|
||||
chbre = self.__proprietaire.chbre()
|
||||
if chbre == 'EXT' and typ == 'fixe' :
|
||||
raise ValueError(u'Il faut une chambre pour pouvoir posséder une machine fixe')
|
||||
|
||||
if chbre == '????' :
|
||||
raise ValueError(u'ERREUR : la chambre du propriétaire est inconnue')
|
||||
|
||||
if typ == 'wifi' :
|
||||
# Génération de la clef IPsec
|
||||
self.ipsec(1)
|
||||
|
@ -1740,8 +1756,6 @@ class machine(base_classes_crans) :
|
|||
if not self.conn : self.connect()
|
||||
|
||||
res = self.conn.search_s(','.join(self.dn.split(',')[1:]),0)
|
||||
if len(res) != 1 : njoqmf
|
||||
|
||||
if 'adherent' in res[0][1]['objectClass'] :
|
||||
self.__proprietaire = adherent(res[0],self._modifiable,self.conn)
|
||||
elif 'club' in res[0][1]['objectClass'] :
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue