diff --git a/intranet/pages/digicode.py b/intranet/pages/digicode.py index f5ce1e43..2ace3a03 100755 --- a/intranet/pages/digicode.py +++ b/intranet/pages/digicode.py @@ -50,20 +50,22 @@ class root: # # methode qui cree un code # - def createCode(self, code=None): + def createCode(self, code=None, adherent=''): try: + if adherent == '': + adherent = cherrypy.session['uid'] if code: try: int(code) if code.__len__() != 6: raise except: - return {'formatErreur':1} - code = crans.impression.digicode.save_code(code, "Intranet (digicode)") + return {'formatErreur':1} + code = crans.impression.digicode.save_code(code, adherent) else: - code = crans.impression.digicode.gen_code("Intranet (digicode)") + code = crans.impression.digicode.gen_code(adherent) 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: cherrypy.log("erreur lors de la creation de code : " + str(e), 'DIGICODE', 1) return {'erreur':str(e)} diff --git a/intranet/pages/impression.py b/intranet/pages/impression.py index cc610317..9484aab4 100755 --- a/intranet/pages/impression.py +++ b/intranet/pages/impression.py @@ -130,8 +130,7 @@ class root: # def etatImprimante(self): try: - try: - return {"printer_state" : "
".join(crans.impression.etat_imprimante.etat()) + return {"printer_state" : "
".join(crans.impression.etat_imprimante.etat())} except Exception, e: return {"printer_state" : 'Imprimante hors ligne'} etatImprimante.exposed = True diff --git a/intranet/pages/monCompte.py b/intranet/pages/monCompte.py index 9751e267..602d1dd1 100755 --- a/intranet/pages/monCompte.py +++ b/intranet/pages/monCompte.py @@ -80,34 +80,7 @@ class monCompte: # annee scolaire (ex 2001-2002) adherent['anneeScolaire'] = str(administrativeYear) + '-' + str(administrativeYear + 1) 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 ############## mailInfos = {} try: @@ -132,38 +105,12 @@ class monCompte: 'values' :t, 'stylesheets' :['monCompte.css'], # 'scripts':['crans.js','passwordGenerator.js'], - 'scripts':['crans_domtab.js','crans.js','passwordGenerator.js'], + 'scripts':['crans_domtab.js','moncompte.js','passwordGenerator.js'], } 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 ########################## @@ -190,7 +137,7 @@ class monCompte: # creer objet facture f = Facture(adh) # /!\ 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) try: # remplacage des virgules @@ -342,101 +289,13 @@ class monCompte: return self.index(message=u'Modification réussie') 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("") - 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 ########################## def newAlias(self, alias): adh = self.__ldap.search('uid=' + cherrypy.session['uid'],'w')['adherent'][0] 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: adh.alias(alias) adh.save() @@ -444,9 +303,9 @@ class monCompte: except ValueError, e: return self.index(error=e.args[0]) 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: - 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") return self.index(message=u'Alias enregistré') newAlias.exposed = True