ajout d'erreurs personalisees et du module digicode
darcs-hash:20061009172906-f46e9-390eff7e704b7cad2f6a4f3ec8a426fbef179d0b.gz
This commit is contained in:
parent
8c44cac872
commit
bd9ead0d89
11 changed files with 158 additions and 23 deletions
|
@ -34,14 +34,14 @@ parser.add_option("-p", "--port",
|
|||
|
||||
# on suppose qu'en version de developpement, le script est lance depuis le shell
|
||||
if (options.dev):
|
||||
cherrypy.config.update(file=os.getcwd() + "/conf/dev.cfg")
|
||||
cherrypy.config.update(file=os.getcwd() + "/conf/intranet.cfg")
|
||||
cherrypy.config.update(file=os.getcwd() + "/conf/dev.cfg")
|
||||
settings={'global': { 'rootDir': os.getcwd() } }
|
||||
cherrypy.config.update(settings)
|
||||
|
||||
else:
|
||||
cherrypy.config.update(file="/usr/scripts/intranet/conf/prod.cfg")
|
||||
cherrypy.config.update(file="/usr/scripts/intranet/conf/intranet.cfg")
|
||||
cherrypy.config.update(file="/usr/scripts/intranet/conf/prod.cfg")
|
||||
|
||||
# changer le port ??
|
||||
if (options.port):
|
||||
|
@ -71,7 +71,7 @@ from plugins.verifdroitsfilter import VerifDroitsFilter
|
|||
class Intranet:
|
||||
__ldap = None
|
||||
def __init__(self):
|
||||
from pages import monCompte, impression, factures
|
||||
from pages import monCompte, impression, factures, digicode
|
||||
self.__ldap = cherrypy.config.configMap["global"]["crans_ldap"]
|
||||
|
||||
# liste des modules disponibles
|
||||
|
@ -80,7 +80,8 @@ class Intranet:
|
|||
self.impression = impression.root()
|
||||
|
||||
# liste des modules en developpement
|
||||
#if (cherrypy.config.configMap["global"]["server.environment"] == "development"):
|
||||
if (cherrypy.config.configMap["global"]["server.environment"] == "development"):
|
||||
self.digicode = digicode.root()
|
||||
|
||||
|
||||
|
||||
|
@ -100,14 +101,23 @@ class Intranet:
|
|||
}
|
||||
info.exposed = True
|
||||
|
||||
'''
|
||||
|
||||
def _cp_on_http_error(self, status, message):
|
||||
cherrypy.response.body = {
|
||||
'template':'error',
|
||||
'values':{'status':status, 'message':message },
|
||||
'standalone':False,
|
||||
}
|
||||
'''
|
||||
if status==403:
|
||||
cherrypy.response.body = {
|
||||
'template':'error403',
|
||||
'values':{'status':status, 'message':message },
|
||||
'standalone':False,
|
||||
}
|
||||
elif status==404:
|
||||
cherrypy.response.body = {
|
||||
'template':'error',
|
||||
'values':{'status':status, 'message':message },
|
||||
'standalone':False,
|
||||
}
|
||||
else:
|
||||
cherrypy._cputil._cp_on_http_error(status, message)
|
||||
|
||||
'''
|
||||
def nounous(self):
|
||||
return "coucou"
|
||||
|
|
|
@ -17,3 +17,6 @@ logDebugInfoFilter.on = False
|
|||
# option pour utiliser mon compre de test chez paypal
|
||||
paypal.businessAdress = "gdetrez-buisness@crans.org"
|
||||
paypal.useSandbox = True
|
||||
|
||||
[/static]
|
||||
staticFilter.dir = "/home/gdetrez/scripts/intranet/static/"
|
||||
|
|
|
@ -9,12 +9,15 @@ sessionFilter.locking = "implicit"
|
|||
|
||||
# ceci est un exemple de definission de droits
|
||||
#[/nounous]
|
||||
#crans.droits="nounou"
|
||||
#crans.droits="Nounou"
|
||||
|
||||
[/]
|
||||
# Now we can work on our filter as with the standard filters
|
||||
templatesEngine.on = True
|
||||
|
||||
[/digicode]
|
||||
crans.droits="Nounou"
|
||||
|
||||
[/static]
|
||||
sessionAuthenticateFilter.on=False
|
||||
sessionFilter.on = False
|
||||
|
|
|
@ -69,7 +69,7 @@ class root:
|
|||
return {"SoldeInsuffisant":1}
|
||||
except Exception, e:
|
||||
return {"erreur":str(e)}
|
||||
return {'code':str(crans.impression.digicode.gen_code(cherrypy.session['uid'])) + "#"}
|
||||
return {'code':str(crans.impression.digicode.gen_code("Impression intranet : " + cherrypy.session['uid'])) + "#"}
|
||||
lancerImpression.exposed = True
|
||||
|
||||
def getUploadedFileListFor(self, adh):
|
||||
|
|
|
@ -55,7 +55,11 @@ class TemplatesFilter(BaseFilter):
|
|||
return {}
|
||||
|
||||
def _useMainTemplate(self, body):
|
||||
t = Template(file='main.tmpl', searchList=[body,{'login':cherrypy.session['uid'], 'environment':cherrypy.config.configMap["global"]["server.environment"]}])
|
||||
try:
|
||||
t = Template(file='main.tmpl', searchList=[body,{'login':cherrypy.session['uid'], 'environment':cherrypy.config.configMap["global"]["server.environment"]}])
|
||||
except:
|
||||
t = Template(file='main.tmpl', searchList=[body,{'login':'', 'environment':cherrypy.config.configMap["global"]["server.environment"]}])
|
||||
|
||||
return str(t)
|
||||
|
||||
|
||||
|
|
|
@ -5,9 +5,19 @@ import cherrypy._cputil
|
|||
# verification des droits
|
||||
##########################
|
||||
#
|
||||
# Application des templates,
|
||||
# avec plein de test chians
|
||||
#
|
||||
def verifDroits(mesDroits, lesDroitsQuilFaut):
|
||||
if not type(mesDroits) == list:
|
||||
raise ValueError, "mesDroits doit etre une liste"
|
||||
if (lesDroitsQuilFaut == "all"):
|
||||
return True
|
||||
if ("Nounou" in mesDroits):
|
||||
return True
|
||||
if type(lesDroitsQuilFaut) == str:
|
||||
return lesDroitsQuilFaut in mesDroits
|
||||
elif type(lesDroitsQuilFaut) == list:
|
||||
return True in [d in mesDroits for d in lesDroitsQuilFaut]
|
||||
return False
|
||||
|
||||
class VerifDroitsFilter(BaseFilter):
|
||||
|
||||
def before_main(self):
|
||||
|
@ -16,7 +26,6 @@ class VerifDroitsFilter(BaseFilter):
|
|||
if not cherrypy.session.get("session_key"):
|
||||
return
|
||||
droits = cherrypy.config.get('crans.droits', 'all')
|
||||
if (droits != "all"):
|
||||
if not droits in cherrypy.session['droits']:
|
||||
raise cherrypy.HTTPError(403, "Vous n'avez pas les droits nécessaires.")
|
||||
if not verifDroits(cherrypy.session['droits'], droits):
|
||||
raise cherrypy.HTTPError(403, "Vous n'avez pas les droits nécessaires pour accéder à cette page.")
|
||||
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
#import cherrypy, sys
|
||||
$sys.path.append(cherrypy.config.get('rootDir'))
|
||||
#from plugins.verifdroitsfilter import verifDroits
|
||||
<div class="framed_gray">
|
||||
<fieldset>
|
||||
<legend>Personnel</legend>
|
||||
|
@ -18,6 +21,19 @@
|
|||
<img src="/static/images/icon_info.png" alt="icon" />
|
||||
<span>Informations utiles</span>
|
||||
</a></li>
|
||||
</ul>
|
||||
</fieldset>
|
||||
<div style="clear:both;"></div>
|
||||
#if verifDroits($cherrypy.session['droits'],'Imprimeur')
|
||||
<fieldset>
|
||||
<legend>Imprimeur</legend>
|
||||
<ul>
|
||||
<li><a href="/digicode">
|
||||
<img src="/static/images/icon_digicode.png" alt="icon" />
|
||||
<span>Digicode</span>
|
||||
</a></li>
|
||||
</ul>
|
||||
</fieldset>
|
||||
<div class="visualClear"></div>
|
||||
#end if
|
||||
</div>
|
||||
|
|
10
intranet/templates/digicode.tmpl
Normal file
10
intranet/templates/digicode.tmpl
Normal file
|
@ -0,0 +1,10 @@
|
|||
#import crans.impression
|
||||
|
||||
<div id="globalDiv">
|
||||
<h1>Gestion des codes pour le local impression</h1>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
<!--
|
||||
Digicode.init();
|
||||
//-->
|
||||
</script>
|
|
@ -1,7 +1,9 @@
|
|||
<!-- img src="/static/images/petitCr@ns.png" alt="logocr@ns" / -->
|
||||
<img style="float:left;clear:left;" src="/static/images/traveaux.png" alt="Traveaux" />
|
||||
<div style="margin-left:200px;">
|
||||
<h1 style="background:#ddd; float:left; width:50%; padding:10px 20px 10px 10px">Erreur $status</h1>
|
||||
|
||||
<div style="clear:both;">
|
||||
<pre style="border:thin black dashed; padding:10px; margin:20px; float:left; color:gray;">$message</pre>
|
||||
|
||||
<form action="send_error_repport" method="POST">
|
||||
<fieldset style="float:left;"><legend>Envoyer un rapport</legend>
|
||||
|
@ -9,13 +11,12 @@
|
|||
<input type="hidden" name="error_message" value="$message">
|
||||
<label for="user_message">Aidez-nous à améliorer l'intranet en nous indiquant comment l'erreur est apparue:</label><br />
|
||||
<textarea style="width:40em;height:10em;" name="user_message"></textarea>
|
||||
<div style="text-align:right;width:100%;border:thin red solid;">
|
||||
<div style="text-align:right;width:100%;">
|
||||
<button name="send" value="oui">Envoyer le rapport et retourner à la page d'accueil</button>
|
||||
</div>
|
||||
</fieldset>
|
||||
</form>
|
||||
|
||||
<pre style="border:thin black dashed; padding:10px; margin:20px; float:left; color:gray;">$message</pre>
|
||||
|
||||
<a href="/" style="display:block;clear:both;">Retour à la page d'accueil</a>
|
||||
</div>
|
||||
|
|
12
intranet/templates/error403.tmpl
Normal file
12
intranet/templates/error403.tmpl
Normal file
|
@ -0,0 +1,12 @@
|
|||
<!-- img src="/static/images/petitCr@ns.png" alt="logocr@ns" / -->
|
||||
<img style="float:left;clear:left;" src="/static/images/DoNotEnter.png" alt="Do Not Enter" />
|
||||
<div style="margin-left:200px;">
|
||||
<h1 style="background:#ddd; float:left; width:50%; padding:10px 20px 10px 10px">Accès interdit</h1>
|
||||
|
||||
<pre style="border:thin black dashed; padding:10px; margin:20px; float:left; color:gray;">$message</pre>
|
||||
|
||||
|
||||
<a href="/" style="display:block;clear:both;">Retour à la page d'accueil</a>
|
||||
</div>
|
||||
|
||||
<div style="clear:both;"></div>
|
67
intranet/templates/impression-devis.tmpl
Normal file
67
intranet/templates/impression-devis.tmpl
Normal file
|
@ -0,0 +1,67 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<meta content="text/html; charset=utf-8" HTTP-EQUIV="Content-Type">
|
||||
<title>Cr@ns Intranet</title>
|
||||
<style type="text/css">
|
||||
table.factureDetails {
|
||||
padding:1%;
|
||||
width:96%;
|
||||
margin:0 1% 10px 1%;
|
||||
}
|
||||
|
||||
.tdTotalDetail,
|
||||
.tdTotalDetailIntitule {
|
||||
border-top:thin black solid;
|
||||
}
|
||||
|
||||
.tdTotalDetailIntitule {
|
||||
text-align:right;
|
||||
font-weight:bold;
|
||||
}
|
||||
|
||||
table.factureDetails th {
|
||||
border-bottom:thin black solid;
|
||||
}
|
||||
table.factureDetails th,
|
||||
table.factureDetails td {
|
||||
border-right:thin black solid;
|
||||
margin:0;
|
||||
padding:5px 20px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div style="background:white url(/static/images/petitCr@ns.png) top left no-repeat; padding:2em;width:21cm;border:thin black solid;">
|
||||
<h1 style="margin:1em 1em 1em 50px;">Devis pour impression</h1>
|
||||
<span style="font-weight:bold;">Fichier : </span> $nomFichier
|
||||
<div id="facture" style="margin:2em 1em 1em 1em;">
|
||||
<table cellspacing="0" border="0" class="factureDetails">
|
||||
<tr>
|
||||
<th width="80%">Description</th>
|
||||
<th>Prix unitaire</th>
|
||||
<th>Quantité</th>
|
||||
|
||||
<th>total</th>
|
||||
</tr>
|
||||
#for anItem in $devis
|
||||
<tr>
|
||||
<td>$anItem[0]</td>
|
||||
<td>$anItem[1] €</td>
|
||||
<td>$anItem[2]</td>
|
||||
<td>
|
||||
#echo str($anItem[1] * $anItem[2]) + ' €'
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
#end for
|
||||
<tr>
|
||||
<td colspan="3" class="tdTotalDetailIntitule">
|
||||
Total
|
||||
</td>
|
||||
<td class="tdTotalDetail">$total €</td>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
Loading…
Add table
Add a link
Reference in a new issue