diff --git a/intranet/Root.py b/intranet/Root.py index ecbec681..f9d4f7fd 100755 --- a/intranet/Root.py +++ b/intranet/Root.py @@ -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" diff --git a/intranet/conf/dev.cfg b/intranet/conf/dev.cfg index 34c4346b..dfd6e8fb 100644 --- a/intranet/conf/dev.cfg +++ b/intranet/conf/dev.cfg @@ -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/" diff --git a/intranet/conf/intranet.cfg b/intranet/conf/intranet.cfg index 3eeee68e..ee8b34d0 100644 --- a/intranet/conf/intranet.cfg +++ b/intranet/conf/intranet.cfg @@ -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 diff --git a/intranet/pages/impression.py b/intranet/pages/impression.py index e8cfef05..83c42a65 100755 --- a/intranet/pages/impression.py +++ b/intranet/pages/impression.py @@ -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): diff --git a/intranet/plugins/templatesfilter.py b/intranet/plugins/templatesfilter.py index b806ffe7..a3003d40 100644 --- a/intranet/plugins/templatesfilter.py +++ b/intranet/plugins/templatesfilter.py @@ -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) diff --git a/intranet/plugins/verifdroitsfilter.py b/intranet/plugins/verifdroitsfilter.py index 8e904b4a..b52f2023 100644 --- a/intranet/plugins/verifdroitsfilter.py +++ b/intranet/plugins/verifdroitsfilter.py @@ -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.") diff --git a/intranet/templates/accueil.tmpl b/intranet/templates/accueil.tmpl index b37e9a76..ff494a2d 100644 --- a/intranet/templates/accueil.tmpl +++ b/intranet/templates/accueil.tmpl @@ -1,3 +1,6 @@ +#import cherrypy, sys +$sys.path.append(cherrypy.config.get('rootDir')) +#from plugins.verifdroitsfilter import verifDroits
Personnel @@ -18,6 +21,19 @@ icon Informations utiles +
+
+ #if verifDroits($cherrypy.session['droits'],'Imprimeur') +
+ Imprimeur + +
+ #end if
diff --git a/intranet/templates/digicode.tmpl b/intranet/templates/digicode.tmpl new file mode 100644 index 00000000..56b1df7d --- /dev/null +++ b/intranet/templates/digicode.tmpl @@ -0,0 +1,10 @@ +#import crans.impression + +
+

Gestion des codes pour le local impression

+
+ diff --git a/intranet/templates/error.tmpl b/intranet/templates/error.tmpl index d6c6a4f8..8c1d174c 100644 --- a/intranet/templates/error.tmpl +++ b/intranet/templates/error.tmpl @@ -1,7 +1,9 @@ +Traveaux +

Erreur $status

-
+
$message
Envoyer un rapport @@ -9,13 +11,12 @@
-
+
-
$message
Retour à la page d'accueil
diff --git a/intranet/templates/error403.tmpl b/intranet/templates/error403.tmpl new file mode 100644 index 00000000..d1fa712c --- /dev/null +++ b/intranet/templates/error403.tmpl @@ -0,0 +1,12 @@ + +Do Not Enter +
+

Accès interdit

+ +
$message
+ + + Retour à la page d'accueil +
+ +
diff --git a/intranet/templates/impression-devis.tmpl b/intranet/templates/impression-devis.tmpl new file mode 100644 index 00000000..06c2eb10 --- /dev/null +++ b/intranet/templates/impression-devis.tmpl @@ -0,0 +1,67 @@ + + + + + Cr@ns Intranet + + + +
+

Devis pour impression

+ Fichier : $nomFichier +
+ + + + + + + + + #for anItem in $devis + + + + + + + + #end for + + + +
DescriptionPrix unitaireQuantitétotal
$anItem[0]$anItem[1] €$anItem[2] + #echo str($anItem[1] * $anItem[2]) + ' €' +
+ Total + $total €
+
+
+ +