corrections pour paypal et mise en place de l'impression
darcs-hash:20061006190234-f46e9-115dab8e0a8c62e5c0ae08d3a1efd1a73769fa65.gz
This commit is contained in:
parent
28a524ffc9
commit
7d4c2f9e68
3 changed files with 117 additions and 16 deletions
|
@ -6,7 +6,7 @@
|
|||
# Description: #
|
||||
# Affiche la liste des factures et l'historique de débits/crédits de l'adhérent. #
|
||||
# Informations: #
|
||||
# Pas d'AJAX ici en principe #
|
||||
# #
|
||||
# Pages: #
|
||||
# index:liste des factures #
|
||||
# historique: historique des débits/crédits #
|
||||
|
@ -39,7 +39,9 @@ class root:
|
|||
'prixTotal':art['pu']*art['nombre'],
|
||||
} for art in f.articles()]
|
||||
facture['montant'] = f.total()
|
||||
facture['paypal'] = f.urlPaypal()
|
||||
facture['paypal'] = f.urlPaypal(useSandbox = cherrypy.config.get("paypal.useSandbox", False),
|
||||
businessMail = cherrypy.config.get("paypal.businessAdress", "paypal@crans.org"))
|
||||
|
||||
facture['payee'] = f.recuPaiement()
|
||||
listeFactures.append(facture)
|
||||
t['listeFactures'] = listeFactures
|
||||
|
@ -55,7 +57,7 @@ class root:
|
|||
def historique(self):
|
||||
adh = self.__ldap.search('uid=' + cherrypy.session['uid'])['adherent'][0]
|
||||
|
||||
lst = [ x for x in adh.historique() if x.split(u' : ',2)[1].startswith(u'credit') or x.split(u' : ',2)[1].startswith(u'debit') ]
|
||||
lst = [ x for x in adh.historique() if x.split(u' : ',1)[1].startswith(u'credit') or x.split(u' : ',1)[1].startswith(u'debit') ]
|
||||
histLst = []
|
||||
for anItem in lst:
|
||||
#11/06/2006 01:40, gdetrez : credit 10.0 Euros [Facture n°1 : Impression]
|
||||
|
@ -75,4 +77,4 @@ class root:
|
|||
'stylesheets' :['cransFactures.css'],
|
||||
'scripts' :[],
|
||||
}
|
||||
historique.exposed = True
|
||||
historique.exposed = True
|
||||
|
|
|
@ -1,5 +1,12 @@
|
|||
#! /usr/bin/env python
|
||||
import cherrypy
|
||||
import cherrypy, tempfile, shutil, os
|
||||
import crans.impression
|
||||
import crans.impression.digicode
|
||||
|
||||
FILE_UPLOAD_BASE_FOLDER = cherrypy.config.get('fileUpload.folder', "/var/impression/fichiers/")
|
||||
|
||||
class FileError(Exception):
|
||||
pass
|
||||
|
||||
class root:
|
||||
|
||||
|
@ -12,12 +19,21 @@ class root:
|
|||
# l'adherent + les formulaires
|
||||
#
|
||||
def index(self, submit = None, fileList = None, newFile = None ):
|
||||
data = {}
|
||||
if (submit == None):
|
||||
data['fileList'] = self.getUploadedFileListFor(cherrypy.session['uid'])
|
||||
else:
|
||||
data['fileName'] = "file1-name.pdf"
|
||||
|
||||
data = {}
|
||||
cherrypy.session['impression'] = None
|
||||
if submit == "submit_send":
|
||||
try:
|
||||
self.savePDF(newFile)
|
||||
data['fileName'] = newFile.filename
|
||||
except FileError, e:
|
||||
data['openError'] = e.args[0]
|
||||
elif submit == "submit_chose":
|
||||
if (fileList):
|
||||
data['fileName'] = fileList
|
||||
else:
|
||||
data['openError'] = "Choisissez un fichier"
|
||||
|
||||
data['fileList'] = self.getUploadedFileListFor(cherrypy.session['uid'])
|
||||
return {'template':'impression',
|
||||
'values':data,
|
||||
'stylesheets':['impression.css'],
|
||||
|
@ -26,5 +42,87 @@ class root:
|
|||
index.exposed = True
|
||||
|
||||
|
||||
def useFile(self, fileName):
|
||||
try:
|
||||
filepath = os.path.join(os.path.join(FILE_UPLOAD_BASE_FOLDER, cherrypy.session['uid']+"/"), fileName)
|
||||
cherrypy.session['impression'] = crans.impression.impression(filepath, cherrypy.session['uid'])
|
||||
return {'nbPages': cherrypy.session['impression'].pages()}
|
||||
except:
|
||||
return {'erreur':'Fichier invalide'}
|
||||
useFile.exposed= True
|
||||
|
||||
|
||||
|
||||
def changeSettings(self, copies=None, couleurs=None, recto_verso=None, agrafes=None, papier=None):
|
||||
try:
|
||||
nouvPrix = cherrypy.session['impression'].changeSettings(papier=papier, couleurs=couleurs, agraphes=agrafes, recto_verso=recto_verso, copies=int(copies))
|
||||
except Exception, e:
|
||||
return {"erreur":e.arg[0]}
|
||||
return {'nouvPrix':nouvPrix}
|
||||
changeSettings.exposed = True
|
||||
|
||||
|
||||
def lancerImpression(self):
|
||||
try:
|
||||
cherrypy.session['impression'].imprime()
|
||||
except crans.impression.SoldeInsuffisant:
|
||||
return {"SoldeInsuffisant":1}
|
||||
except Exception, e:
|
||||
return {"erreur":str(e)}
|
||||
return {'code':str(crans.impression.digicode.gen_code(cherrypy.session['uid'])) + "#"}
|
||||
lancerImpression.exposed = True
|
||||
|
||||
def getUploadedFileListFor(self, adh):
|
||||
return ['file1.pdf', 'file2.pdf', 'file3.pdf', 'file4.pdf', 'file5.pdf']
|
||||
file_folder = os.path.join(FILE_UPLOAD_BASE_FOLDER, cherrypy.session['uid']+"/")
|
||||
if not os.path.isdir(file_folder):
|
||||
return []
|
||||
return os.listdir(file_folder)
|
||||
|
||||
|
||||
def savePDF(self, aFile):
|
||||
|
||||
_, tempFileName = tempfile.mkstemp()
|
||||
f = open(tempFileName, 'w+b')
|
||||
size=0
|
||||
while True:
|
||||
data = aFile.file.read(1024 * 8) # Read blocks of 8KB at a time
|
||||
if not data:
|
||||
break
|
||||
f.write(data)
|
||||
size += len(data)
|
||||
f.close()
|
||||
if size == 0:
|
||||
raise FileError("Fichier vide")
|
||||
|
||||
file_folder = os.path.join(FILE_UPLOAD_BASE_FOLDER, cherrypy.session['uid']+"/")
|
||||
if not os.path.isdir(file_folder):
|
||||
os.makedirs(file_folder)
|
||||
newFilePath = os.path.join(file_folder, aFile.filename)
|
||||
shutil.move(tempFileName, newFilePath)
|
||||
|
||||
return newFilePath
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
##########################
|
||||
# devis
|
||||
##########################
|
||||
#
|
||||
# methode qui affiche la template du devis
|
||||
#
|
||||
|
||||
def devis(self):
|
||||
return {
|
||||
'template':'impression-devis',
|
||||
'values':
|
||||
{
|
||||
'devis':cherrypy.session['impression'].devisDetaille(),
|
||||
'total':cherrypy.session['impression'].prix(),
|
||||
'nomFichier':cherrypy.session['impression'].fileName(),
|
||||
},
|
||||
'standalone':True,
|
||||
}
|
||||
devis.exposed=True
|
||||
|
|
|
@ -7,10 +7,10 @@ sys.path.append('/usr/scripts/gestion/')
|
|||
from config_mail import MailConfig
|
||||
if (cherrypy.config.configMap["global"]["server.environment"] == "development"):
|
||||
from ldap_crans_test import *
|
||||
print("monCompte : unsing test ldap : env=" + cherrypy.config.configMap["global"]["server.environment"])
|
||||
# print("monCompte : unsing test ldap : env=" + cherrypy.config.configMap["global"]["server.environment"])
|
||||
else:
|
||||
from ldap_crans import *
|
||||
print("monCompte : unsing prod ldap : env=" + cherrypy.config.configMap["global"]["server.environment"])
|
||||
# print("monCompte : unsing prod ldap : env=" + cherrypy.config.configMap["global"]["server.environment"])
|
||||
|
||||
|
||||
|
||||
|
@ -221,7 +221,8 @@ class monCompte:
|
|||
return {
|
||||
'template' :'MonCompteRechargePaypal4',
|
||||
'standalone' :True,
|
||||
'values' :{'lienPaypal' : f.urlPaypal()},
|
||||
'values' :{'lienPaypal' : f.urlPaypal(useSandbox = cherrypy.config.get("paypal.useSandbox", False),
|
||||
businessMail = cherrypy.config.get("paypal.businessAdress", "paypal@crans.org"))},
|
||||
}
|
||||
rechargerCompteImpression.exposed = True
|
||||
|
||||
|
@ -394,7 +395,7 @@ class monCompte:
|
|||
del m
|
||||
except ValueError, e:
|
||||
del m
|
||||
return {'error':e.args[0]}
|
||||
return {'error':e.args[0].replace("\n","\\n")}
|
||||
return {'message':u"Machine enregistrée avec succès"}
|
||||
creerMachine.exposed = True
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue