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