[gest_crans_lc] Génération de l'historique
This commit is contained in:
parent
5fd4098584
commit
fda4e6051a
1 changed files with 24 additions and 1 deletions
|
@ -69,7 +69,7 @@ def mydebug(txt):
|
|||
# voir http://kylem.net/programming/tailcall.html
|
||||
# je trouve ça assez sioux
|
||||
# En plus, ça nous permet de gérer plus facilement le
|
||||
# code en CPS
|
||||
# code en CPS (Continuation Passing Style)
|
||||
class TailCaller(object) :
|
||||
"""
|
||||
Classe permetant, en décorant des fonctions avec, d'avoir de la tail récursion
|
||||
|
@ -556,6 +556,7 @@ class GestCrans(object):
|
|||
try:
|
||||
with self.conn.search(dn=obj.dn, scope=0, mode='rw')[0] as obj:
|
||||
obj['blacklist'].append(bl)
|
||||
obj.history_gen()
|
||||
obj.save()
|
||||
# On s'en va en mettant à jour dans la continuation la valeur de obj
|
||||
raise Continue(self_cont(bl=None, obj=obj))
|
||||
|
@ -610,6 +611,7 @@ class GestCrans(object):
|
|||
try:
|
||||
with self.conn.search(dn=obj.dn, scope=0, mode='rw')[0] as obj:
|
||||
obj['blacklist'][int(tag)]=bl
|
||||
obj.history_gen()
|
||||
obj.save()
|
||||
# On s'en va en mettant à jour dans la continuation la valeur de obj
|
||||
raise Continue(self_cont(bl=None, obj=obj))
|
||||
|
@ -653,6 +655,7 @@ class GestCrans(object):
|
|||
obj[a.ldap_name]=values[a.ldap_name]
|
||||
elif not obj[a.ldap_name] and missing.get(a, missing['default']) != values[a.ldap_name]:
|
||||
obj[a.ldap_name]=values[a.ldap_name]
|
||||
obj.history_gen()
|
||||
obj.save()
|
||||
# On s'en va en mettant à jour dans la continuation la valeur de obj
|
||||
raise Continue(cont(**{update_obj:obj}))
|
||||
|
@ -709,6 +712,7 @@ class GestCrans(object):
|
|||
def todo(obj, values, cont):
|
||||
with self.conn.search(dn=obj.dn, scope=0, mode='rw')[0] as obj:
|
||||
obj[attr] = [unicode(value, 'utf-8') for value in values]
|
||||
obj.history_gen()
|
||||
obj.save()
|
||||
raise Continue(cont(**{update_obj:obj}))
|
||||
|
||||
|
@ -1053,6 +1057,7 @@ class GestCrans(object):
|
|||
for (key, values) in attrs.items():
|
||||
machine[key]=values
|
||||
machine.validate_changes()
|
||||
machine.history_gen()
|
||||
machine.save()
|
||||
return machine
|
||||
|
||||
|
@ -1175,6 +1180,7 @@ les valeurs valident sont :
|
|||
certificat.tlsa(values['certificatUsage'], values['matchingType'])
|
||||
certificat['portTCPin'] = [unicode(s, 'utf-8') for s in values['portTCPin'].split(separateur) if s]
|
||||
certificat['portUDPin'] = [unicode(s, 'utf-8') for s in values['portUDPin'].split(separateur) if s]
|
||||
certificat.history_gen()
|
||||
certificat.save()
|
||||
raise Continue(cont(certificat=certificat))
|
||||
|
||||
|
@ -1214,6 +1220,7 @@ les valeurs valident sont :
|
|||
if certificat:
|
||||
with self.conn.search(dn=certificat.dn, scope=0, mode='rw')[0] as certificat:
|
||||
certificat['certificat'] = unicode(pem.strip(), 'utf-8')
|
||||
certificat.history_gen()
|
||||
certificat.save()
|
||||
else:
|
||||
with self.conn.newCertificat(machine.dn, {}) as certificat:
|
||||
|
@ -1304,6 +1311,7 @@ les valeurs valident sont :
|
|||
raise ValueError("Il y a déjà une clef privée, merci d'annuler")
|
||||
with self.conn.search(dn=certificat.dn, scope=0, mode='rw')[0] as certificat:
|
||||
certificat.private(pem, encrypted=True)
|
||||
certificat.history_gen()
|
||||
certificat.save()
|
||||
self.dialog.msgbox("Clef privée bien ajouté", timeout=self.timeout, title="Ajout d'une clef privée")
|
||||
raise Continue(cont(certificat=certificat, machine=certificat.machine()))
|
||||
|
@ -1388,6 +1396,7 @@ les valeurs valident sont :
|
|||
csr = crypto.dump_certificate_request(crypto.FILETYPE_PEM, req)
|
||||
with self.conn.search(dn=certificat.dn, scope=0, mode='rw')[0] as certificat:
|
||||
certificat['csr']=unicode(csr)
|
||||
certificat.history_gen()
|
||||
certificat.save()
|
||||
self.handle_dialog(cont, box, csr)
|
||||
if self.dialog.yesno("Remplacer le certificat actuel ?", timeout=self.timeout) == self.dialog.DIALOG_OK:
|
||||
|
@ -1448,6 +1457,7 @@ les valeurs valident sont :
|
|||
if certificat:
|
||||
with self.conn.search(dn=certificat.dn, scope=0, mode='rw')[0] as certificat:
|
||||
certificat['csr'] = unicode(pem.strip(), 'utf-8')
|
||||
certificat.history_gen()
|
||||
certificat.save()
|
||||
else:
|
||||
with self.conn.newCertificat(machine.dn, {}) as certificat:
|
||||
|
@ -2028,6 +2038,7 @@ les valeurs valident sont :
|
|||
adherent["controle"]=unicode(adherent["controle"][0]).replace('c','')
|
||||
if not adherent["controle"][0]:
|
||||
adherent["controle"] = []
|
||||
adherent.history_gen()
|
||||
adherent.save()
|
||||
# On s'en va en mettant à jour dans la continuation la valeur de obj
|
||||
raise Continue(cont(adherent=adherent))
|
||||
|
@ -2110,6 +2121,7 @@ les valeurs valident sont :
|
|||
for (key, values) in attrs.items():
|
||||
adherent[key]=values
|
||||
adherent.validate_changes()
|
||||
adherent.history_gen()
|
||||
adherent.save()
|
||||
return adherent
|
||||
|
||||
|
@ -2210,6 +2222,7 @@ les valeurs valident sont :
|
|||
text_bottom=u"\nPasser la chambre de cet adhérent en chambre inconnue ?"
|
||||
):
|
||||
squatteur['chbre']=u'????'
|
||||
squatteur.history_gen()
|
||||
squatteur.save()
|
||||
return True
|
||||
else:
|
||||
|
@ -2237,6 +2250,7 @@ les valeurs valident sont :
|
|||
else:
|
||||
with self.conn.search(dn=adherent.dn, scope=0, mode='rw')[0] as adherent:
|
||||
adherent = set_chambre(adherent, chbre)
|
||||
adherent.history_gen()
|
||||
adherent.save()
|
||||
self.display_item(item=adherent, title="Adhérent déménagé dans la chambre %s" % output)
|
||||
raise Continue(success_cont(adherent=adherent))
|
||||
|
@ -2274,6 +2288,7 @@ les valeurs valident sont :
|
|||
with self.conn.search(dn=adherent.dn, scope=0, mode='rw')[0] as adherent:
|
||||
adherent['postalAddress']=[unicode(pa, 'utf-8') for pa in output]
|
||||
adherent['chbre']=u'EXT'
|
||||
adherent.history_gen()
|
||||
adherent.save()
|
||||
self.display_item(item=adherent, title="Adhérent déménégé hors campus, machines conservées")
|
||||
raise Continue(success_cont(adherent=adherent))
|
||||
|
@ -2300,6 +2315,7 @@ les valeurs valident sont :
|
|||
with machine:
|
||||
machine.delete()
|
||||
adherent['chbre']=u'EXT'
|
||||
adherent.history_gen()
|
||||
adherent.save()
|
||||
self.display_item(item=adherent, title="Adhérent déménégé hors campus, machines supprimées")
|
||||
raise Continue(success_cont(adherent=adherent))
|
||||
|
@ -2327,6 +2343,7 @@ les valeurs valident sont :
|
|||
with machine:
|
||||
machine.delete()
|
||||
adherent['chbre']=u'EXT'
|
||||
adherent.history_gen()
|
||||
adherent.save()
|
||||
# On supprime le compte crans (on essaye)
|
||||
def post_deletion(proprio, cont):
|
||||
|
@ -2481,6 +2498,7 @@ les valeurs valident sont :
|
|||
if not self.confirm_item(item=proprio, title="Création du compte crans pour l'adhérent ?"):
|
||||
raise Continue(cont)
|
||||
else:
|
||||
proprio.history_gen()
|
||||
proprio.save()
|
||||
self.dialog.msgbox(
|
||||
text="Compte créé avec succès.",
|
||||
|
@ -2524,6 +2542,7 @@ les valeurs valident sont :
|
|||
else:
|
||||
with self.conn.search(dn=proprio.dn, scope=0, mode='rw')[0] as proprio:
|
||||
proprio['userPassword']=unicode(lc_utils.hash_password(password))
|
||||
proprio.history_gen()
|
||||
proprio.save()
|
||||
self.dialog.msgbox(
|
||||
"Mot de passe changé avec succès",
|
||||
|
@ -2558,6 +2577,7 @@ les valeurs valident sont :
|
|||
raise ValueError("Il faut entrer une adresse mail")
|
||||
with self.conn.search(dn=proprio.dn, scope=0, mode='rw')[0] as proprio:
|
||||
proprio.delete_compte(unicode(mail, 'utf-8'))
|
||||
proprio.history_gen()
|
||||
proprio.save()
|
||||
self.dialog.msgbox("Le compte a bien été supprimée", timeout=self.timeout, title="Suppression du compte de %s %s" % (proprio.get('prenom', [''])[0], proprio["nom"][0]))
|
||||
raise Continue(cont(proprio=proprio))
|
||||
|
@ -2580,6 +2600,7 @@ les valeurs valident sont :
|
|||
proprio["shadowExpire"]=0
|
||||
else:
|
||||
proprio["shadowExpire"]=[]
|
||||
proprio.history_gen()
|
||||
proprio.save()
|
||||
raise Continue(cont(proprio=proprio))
|
||||
|
||||
|
@ -2621,6 +2642,7 @@ les valeurs valident sont :
|
|||
if shell and shell != output:
|
||||
with self.conn.search(dn=proprio.dn, scope=0, mode='rw')[0] as proprio:
|
||||
proprio['loginShell']=unicode(loginShell)
|
||||
proprio.history_gen()
|
||||
proprio.save()
|
||||
self.dialog.msgbox("Shell modifié avec succès.\nLa modification peut prendre une quainzaine de minute avant d'être effective.",
|
||||
title="Shell de %s %s" % (proprio.get('prenom', [""])[0], proprio['nom'][0]),
|
||||
|
@ -2730,6 +2752,7 @@ les valeurs valident sont :
|
|||
# Les vérifications de sécurité sont faites dans lc_ldap
|
||||
with self.conn.search(dn=adherent.dn, scope=0, mode='rw')[0] as adherent:
|
||||
adherent['droits']=[unicode(d) for d in droits]
|
||||
adherent.history_gen()
|
||||
adherent.save()
|
||||
if adherent["uid"] and adherent["uid"][0] == self.conn.current_login:
|
||||
self.check_ldap()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue