crer des codes pour les adhrents
darcs-hash:20061110134010-f46e9-0b0fbd4245cd5a688b78e63e84842d07395cdb29.gz
This commit is contained in:
parent
e8391dfd40
commit
cd694cff0c
3 changed files with 14 additions and 154 deletions
|
@ -50,8 +50,10 @@ class root:
|
||||||
#
|
#
|
||||||
# methode qui cree un code
|
# methode qui cree un code
|
||||||
#
|
#
|
||||||
def createCode(self, code=None):
|
def createCode(self, code=None, adherent=''):
|
||||||
try:
|
try:
|
||||||
|
if adherent == '':
|
||||||
|
adherent = cherrypy.session['uid']
|
||||||
if code:
|
if code:
|
||||||
try:
|
try:
|
||||||
int(code)
|
int(code)
|
||||||
|
@ -59,11 +61,11 @@ class root:
|
||||||
raise
|
raise
|
||||||
except:
|
except:
|
||||||
return {'formatErreur':1}
|
return {'formatErreur':1}
|
||||||
code = crans.impression.digicode.save_code(code, "Intranet (digicode)")
|
code = crans.impression.digicode.save_code(code, adherent)
|
||||||
else:
|
else:
|
||||||
code = crans.impression.digicode.gen_code("Intranet (digicode)")
|
code = crans.impression.digicode.gen_code(adherent)
|
||||||
cherrypy.log("code cree : %s" % code, 'DIGICODE')
|
cherrypy.log("code cree : %s" % code, 'DIGICODE')
|
||||||
return {'code': code, "age" : "new", "desc":"Intranet (digicode)"}
|
return {'code': code, "age" : "new", "desc":adherent}
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
cherrypy.log("erreur lors de la creation de code : " + str(e), 'DIGICODE', 1)
|
cherrypy.log("erreur lors de la creation de code : " + str(e), 'DIGICODE', 1)
|
||||||
return {'erreur':str(e)}
|
return {'erreur':str(e)}
|
||||||
|
|
|
@ -130,8 +130,7 @@ class root:
|
||||||
#
|
#
|
||||||
def etatImprimante(self):
|
def etatImprimante(self):
|
||||||
try:
|
try:
|
||||||
try:
|
return {"printer_state" : "<br />".join(crans.impression.etat_imprimante.etat())}
|
||||||
return {"printer_state" : "<br />".join(crans.impression.etat_imprimante.etat())
|
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
return {"printer_state" : 'Imprimante hors ligne'}
|
return {"printer_state" : 'Imprimante hors ligne'}
|
||||||
etatImprimante.exposed = True
|
etatImprimante.exposed = True
|
||||||
|
|
|
@ -81,33 +81,6 @@ class monCompte:
|
||||||
adherent['anneeScolaire'] = str(administrativeYear) + '-' + str(administrativeYear + 1)
|
adherent['anneeScolaire'] = str(administrativeYear) + '-' + str(administrativeYear + 1)
|
||||||
t['adherent'] = adherent
|
t['adherent'] = adherent
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
############## info machines ##############
|
|
||||||
machines = []
|
|
||||||
for une_machine in adh.machines():
|
|
||||||
machineInfos = {}
|
|
||||||
# nom, mac, mid, ip
|
|
||||||
machineInfos['id'] = une_machine.nom
|
|
||||||
machineInfos['nom'] = une_machine.nom
|
|
||||||
machineInfos['nomCourt'] = une_machine.nom().split('.',1)[0]
|
|
||||||
machineInfos['mac'] = une_machine.mac
|
|
||||||
machineInfos['mid'] = une_machine.id()
|
|
||||||
machineInfos['ip'] = une_machine.ip()
|
|
||||||
# type
|
|
||||||
if une_machine.objectClass == 'machineFixe':
|
|
||||||
machineInfos['type'] = 'Machine fixe'
|
|
||||||
else:
|
|
||||||
machineInfos['type'] = 'Machine wifi'
|
|
||||||
# clef ipsec
|
|
||||||
try:
|
|
||||||
machineInfos['ipsec'] = une_machine.ipsec
|
|
||||||
except:
|
|
||||||
machineInfos['ipsec'] = ''
|
|
||||||
machines.append(machineInfos)
|
|
||||||
t['machines'] = machines
|
|
||||||
|
|
||||||
############## info mail ##############
|
############## info mail ##############
|
||||||
mailInfos = {}
|
mailInfos = {}
|
||||||
try:
|
try:
|
||||||
|
@ -132,38 +105,12 @@ class monCompte:
|
||||||
'values' :t,
|
'values' :t,
|
||||||
'stylesheets' :['monCompte.css'],
|
'stylesheets' :['monCompte.css'],
|
||||||
# 'scripts':['crans.js','passwordGenerator.js'],
|
# 'scripts':['crans.js','passwordGenerator.js'],
|
||||||
'scripts':['crans_domtab.js','crans.js','passwordGenerator.js'],
|
'scripts':['crans_domtab.js','moncompte.js','passwordGenerator.js'],
|
||||||
}
|
}
|
||||||
index.exposed = True
|
index.exposed = True
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def listeMachines(self):
|
|
||||||
adh = self.__ldap.search('uid=' + cherrypy.session['uid'])['adherent'][0]
|
|
||||||
machines = []
|
|
||||||
for une_machine in adh.machines():
|
|
||||||
machineInfos = {}
|
|
||||||
# nom, mac, mid, ip
|
|
||||||
machineInfos['nom'] = une_machine.nom()
|
|
||||||
machineInfos['nomCourt'] = une_machine.nom().split('.',1)[0]
|
|
||||||
machineInfos['mac'] = une_machine.mac()
|
|
||||||
machineInfos['mid'] = une_machine.id()
|
|
||||||
machineInfos['ip'] = une_machine.ip()
|
|
||||||
# type
|
|
||||||
if une_machine.objectClass == 'machineFixe':
|
|
||||||
machineInfos['type'] = 'Machine fixe'
|
|
||||||
else:
|
|
||||||
machineInfos['type'] = 'Machine wifi'
|
|
||||||
# clef ipsec
|
|
||||||
try:
|
|
||||||
machineInfos['ipsec'] = une_machine.ipsec()
|
|
||||||
except:
|
|
||||||
machineInfos['ipsec'] = ''
|
|
||||||
machines.append(machineInfos)
|
|
||||||
return {'machines':machines}
|
|
||||||
listeMachines.exposed = True
|
|
||||||
|
|
||||||
|
|
||||||
##########################
|
##########################
|
||||||
# paypal
|
# paypal
|
||||||
##########################
|
##########################
|
||||||
|
@ -190,7 +137,7 @@ class monCompte:
|
||||||
# creer objet facture
|
# creer objet facture
|
||||||
f = Facture(adh)
|
f = Facture(adh)
|
||||||
# /!\ verifier que combien est un nombre
|
# /!\ verifier que combien est un nombre
|
||||||
# et qu'il n'y a pas plus de 2 chiffres après le point...
|
# et qu'il n'y a pas plus de 2 chiffres après le point...
|
||||||
# (ce serait bien aussi si on pouvait mettre une virgue a la place du point)
|
# (ce serait bien aussi si on pouvait mettre une virgue a la place du point)
|
||||||
try:
|
try:
|
||||||
# remplacage des virgules
|
# remplacage des virgules
|
||||||
|
@ -342,101 +289,13 @@ class monCompte:
|
||||||
return self.index(message=u'Modification réussie')
|
return self.index(message=u'Modification réussie')
|
||||||
changeTelAdherent.exposed = True
|
changeTelAdherent.exposed = True
|
||||||
|
|
||||||
##########################
|
|
||||||
# machine:nom
|
|
||||||
##########################
|
|
||||||
def changeNomMachine(self, mid, nouveauNom):
|
|
||||||
adh = self.__ldap.search('uid=' + cherrypy.session['uid'])['adherent'][0]
|
|
||||||
mach = self.__ldap.search('mid=' + mid, 'w')['machine'][0]
|
|
||||||
# tester si c'est bien la machine de l'adherent
|
|
||||||
if mach.proprietaire().compte() != cherrypy.session['uid']:
|
|
||||||
del adh, mach
|
|
||||||
raise Exception(u"L'uid de l'adherent ne correspond mas au proprietaire de la machine.")
|
|
||||||
try:
|
|
||||||
mach.nom(nouveauNom)
|
|
||||||
mach.save()
|
|
||||||
del mach
|
|
||||||
except ValueError, e:
|
|
||||||
del mach
|
|
||||||
return {'error':e.args[0]}
|
|
||||||
cherrypy.log("Change nom machine", "MONCOMPTE ACTION")
|
|
||||||
return {'message':u"Modification réussie"}
|
|
||||||
changeNomMachine.exposed = True
|
|
||||||
|
|
||||||
##########################
|
|
||||||
# machine:mac
|
|
||||||
##########################
|
|
||||||
def changeMACMachine(self, mid, nouvelleMAC):
|
|
||||||
adh = self.__ldap.search('uid=' + cherrypy.session['uid'])['adherent'][0]
|
|
||||||
mach = self.__ldap.search('mid=' + mid, 'w')['machine'][0]
|
|
||||||
# tester si c'est bien la machine de l'adherent
|
|
||||||
if mach.proprietaire().compte() != cherrypy.session['uid']:
|
|
||||||
del adh, mach
|
|
||||||
raise Exception(u"L'uid de l'adherent ne correspond mas au proprietaire de la machine.")
|
|
||||||
|
|
||||||
try:
|
|
||||||
mach.mac(nouvelleMAC)
|
|
||||||
mach.save()
|
|
||||||
del mach
|
|
||||||
except ValueError, e:
|
|
||||||
del mach
|
|
||||||
return {'error':e.args[0]}
|
|
||||||
cherrypy.log("Change mac machine", "MONCOMPTE ACTION")
|
|
||||||
return {'message':u"Modification réussie"}
|
|
||||||
changeMACMachine.exposed = True
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
##########################
|
|
||||||
# machine:suppression
|
|
||||||
##########################
|
|
||||||
def supprimeMachine(self, mid):
|
|
||||||
adh = self.__ldap.search('uid=' + cherrypy.session['uid'])['adherent'][0]
|
|
||||||
mach = self.__ldap.search('mid=' + mid, 'w')['machine'][0]
|
|
||||||
# tester si c'est bien la machine de l'adherent
|
|
||||||
if mach.proprietaire().compte() != cherrypy.session['uid']:
|
|
||||||
del adh, mach
|
|
||||||
raise Exception(u"L'uid de l'adherent ne correspond mas au proprietaire de la machine.")
|
|
||||||
try:
|
|
||||||
mach.delete()
|
|
||||||
except ValueError, e:
|
|
||||||
return {'error':e.args[0]}
|
|
||||||
cherrypy.log("Machine supprimee", "MONCOMPTE ACTION")
|
|
||||||
return {'message':u"Machine supprimée"}
|
|
||||||
supprimeMachine.exposed = True
|
|
||||||
|
|
||||||
##########################
|
|
||||||
# machine:creation
|
|
||||||
##########################
|
|
||||||
def creerMachine(self, nomNouvelleMachine, MACNouvelleMachine, estMachineWifi='0'):
|
|
||||||
adh = self.__ldap.search('uid=' + cherrypy.session['uid'])['adherent'][0]
|
|
||||||
if estMachineWifi=='0' and adh.droits() == [] and adh.machines_fixes() != []:
|
|
||||||
return {'error':'Vous avez deja une machine fixe. Vous ne pouvez ajouter que des machines WiFi.'}
|
|
||||||
try:
|
|
||||||
if estMachineWifi=='true':
|
|
||||||
m = MachineWifi(adh)
|
|
||||||
else:
|
|
||||||
m = MachineFixe(adh)
|
|
||||||
m.nom(nomNouvelleMachine)
|
|
||||||
m.mac(MACNouvelleMachine)
|
|
||||||
m.ip("<automatique>")
|
|
||||||
message = m.save()
|
|
||||||
del m
|
|
||||||
except ValueError, e:
|
|
||||||
del m
|
|
||||||
return {'error':e.args[0].replace("\n","\\n")}
|
|
||||||
cherrypy.log("Nouvelle machine", "MONCOMPTE ACTION")
|
|
||||||
return {'message':u"Machine enregistrée avec succès"}
|
|
||||||
creerMachine.exposed = True
|
|
||||||
|
|
||||||
|
|
||||||
##########################
|
##########################
|
||||||
# mail:alias:creation
|
# mail:alias:creation
|
||||||
##########################
|
##########################
|
||||||
def newAlias(self, alias):
|
def newAlias(self, alias):
|
||||||
adh = self.__ldap.search('uid=' + cherrypy.session['uid'],'w')['adherent'][0]
|
adh = self.__ldap.search('uid=' + cherrypy.session['uid'],'w')['adherent'][0]
|
||||||
if adh.alias().__len__() >= 3:
|
if adh.alias().__len__() >= 3:
|
||||||
return self.index(error=u"Vous avez plus de 2 alias. Demander à un câbleur pour en rajouter.")
|
return self.index(error=u"Vous avez plus de 2 alias. Demander à un câbleur pour en rajouter.")
|
||||||
try:
|
try:
|
||||||
adh.alias(alias)
|
adh.alias(alias)
|
||||||
adh.save()
|
adh.save()
|
||||||
|
@ -444,9 +303,9 @@ class monCompte:
|
||||||
except ValueError, e:
|
except ValueError, e:
|
||||||
return self.index(error=e.args[0])
|
return self.index(error=e.args[0])
|
||||||
except RuntimeError:
|
except RuntimeError:
|
||||||
return self.index(error=u"Vous possédez déjà cet alias")
|
return self.index(error=u"Vous possèdez déjà cet alias")
|
||||||
except EnvironmentError:
|
except EnvironmentError:
|
||||||
return self.index(error=u"Vous possédez déjà cet alias")
|
return self.index(error=u"Vous possèdez déjà cet alias")
|
||||||
cherrypy.log("Nouvel alias", "MONCOMPTE ACTION")
|
cherrypy.log("Nouvel alias", "MONCOMPTE ACTION")
|
||||||
return self.index(message=u'Alias enregistré')
|
return self.index(message=u'Alias enregistré')
|
||||||
newAlias.exposed = True
|
newAlias.exposed = True
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue