[lib/impression, intranet/impression] stripping trailing whitespaces

Ignore-this: a462d23b95fcfc99372f15a2dc645851

darcs-hash:20090516013103-bd074-7538108fca4203285f67d9f4adff82ade6c33f62.gz
This commit is contained in:
Antoine Durand-Gasselin 2009-05-16 03:31:03 +02:00
parent 5f5b832609
commit fdfd2254d3
6 changed files with 71 additions and 72 deletions

View file

@ -4,7 +4,7 @@ import cherrypy._cputil
########################## ##########################
# DomFilter # DomFilter
########################## ##########################
# #
# transforme des objets python # transforme des objets python
# en chainses de caracteres qui peuvent # en chainses de caracteres qui peuvent
# etre parsees avec JSON/javascript # etre parsees avec JSON/javascript
@ -15,24 +15,24 @@ class DOMFilter(BaseFilter):
if isinstance(body, dict): if isinstance(body, dict):
body = self.printAsDom(body) body = self.printAsDom(body)
cherrypy.response.body = body cherrypy.response.body = body
def printAsDom(self, chose): def printAsDom(self, chose):
if isinstance(chose, dict): if isinstance(chose, dict):
stringList = [] stringList = []
for a_key in chose.keys(): for a_key in chose.keys():
stringList.append('%s:%s' % (self.printAsDom(a_key), self.printAsDom(chose[a_key]))) stringList.append('%s:%s' % (self.printAsDom(a_key), self.printAsDom(chose[a_key])))
return "{%s}" % ','.join(stringList) return "{%s}" % ','.join(stringList)
if isinstance(chose, list): if isinstance(chose, list):
stringList = [] stringList = []
for an_item in chose: for an_item in chose:
stringList.append('%s' % (self.printAsDom(an_item))) stringList.append('%s' % (self.printAsDom(an_item)))
return "[%s]" % ','.join(stringList) return "[%s]" % ','.join(stringList)
if isinstance(chose, str): if isinstance(chose, str):
return '"%s"' % chose return '"%s"' % chose
if isinstance(chose, unicode): if isinstance(chose, unicode):
return '"%s"' % chose.encode('utf8') return '"%s"' % chose.encode('utf8')
return str(chose) return str(chose)

View file

@ -1,4 +1,4 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from cherrypy.filters.basefilter import BaseFilter from cherrypy.filters.basefilter import BaseFilter
import cherrypy, os import cherrypy, os
from Cheetah.Template import Template from Cheetah.Template import Template
@ -21,16 +21,16 @@ def serverSidePath(self, path):
except: except:
pass pass
return root_dir + '/templates/' + path return root_dir + '/templates/' + path
# on surcharge cette fonction dans la classe Template # on surcharge cette fonction dans la classe Template
Template.serverSidePath = serverSidePath Template.serverSidePath = serverSidePath
########################## ##########################
# templatesEngine # templatesEngine
########################## ##########################
# #
# Application des templates, # Application des templates,
# avec plein de test chians # avec plein de test chians
# #
class TemplatesFilter(BaseFilter): class TemplatesFilter(BaseFilter):
@ -46,8 +46,8 @@ class TemplatesFilter(BaseFilter):
def static(truc): def static(truc):
return "/static/" + truc return "/static/" + truc
return static return static
def _getBodyTemplate(self, body): def _getBodyTemplate(self, body):
if isinstance(body, dict): if isinstance(body, dict):
if body.has_key('template'): if body.has_key('template'):
@ -58,7 +58,7 @@ class TemplatesFilter(BaseFilter):
else: else:
return body['template'] + ".tmpl" return body['template'] + ".tmpl"
return False return False
def _isStandaloneBody(self, body): def _isStandaloneBody(self, body):
if isinstance(body, dict): if isinstance(body, dict):
if body.has_key('standalone'): if body.has_key('standalone'):
@ -68,14 +68,14 @@ class TemplatesFilter(BaseFilter):
else: else:
return True return True
return True return True
def _getBodyNameSpace(self, body): def _getBodyNameSpace(self, body):
if isinstance(body, dict): if isinstance(body, dict):
if body.has_key('values'): if body.has_key('values'):
return body['values'] return body['values']
return {} return {}
def _useMainTemplate(self, body): def _useMainTemplate(self, body):
values = {'environment':cherrypy.config.configMap["global"]["server.environment"], values = {'environment':cherrypy.config.configMap["global"]["server.environment"],
'static':self._getCorrectStaticMethod(), 'static':self._getCorrectStaticMethod(),
@ -84,9 +84,9 @@ class TemplatesFilter(BaseFilter):
t = Template(file='main.tmpl', searchList= [body,{'login':cherrypy.session['uid']}, values]) t = Template(file='main.tmpl', searchList= [body,{'login':cherrypy.session['uid']}, values])
except: except:
t = Template(file='main.tmpl', searchList=[body,{'login':''},values]) t = Template(file='main.tmpl', searchList=[body,{'login':''},values])
return t.__str__() return t.__str__()
def goWithThisDict(self, aDict): def goWithThisDict(self, aDict):
body = aDict body = aDict
bodyTemplate = self._getBodyTemplate(body) bodyTemplate = self._getBodyTemplate(body)
@ -95,17 +95,17 @@ class TemplatesFilter(BaseFilter):
defaultvalues = {'static':self._getCorrectStaticMethod()} defaultvalues = {'static':self._getCorrectStaticMethod()}
t = Template(file=bodyTemplate, searchList=[templatevalues, defaultvalues]) t = Template(file=bodyTemplate, searchList=[templatevalues, defaultvalues])
body['page'] = t.__str__() body['page'] = t.__str__()
if not self._isStandaloneBody(body): if not self._isStandaloneBody(body):
body = self._useMainTemplate(body) body = self._useMainTemplate(body)
else: else:
body = body["page"] body = body["page"]
body.encode("utf8") body.encode("utf8")
cherrypy.response.body = body cherrypy.response.body = body
def beforeFinalize(self): def beforeFinalize(self):
body = cherrypy.response.body body = cherrypy.response.body
if isinstance(body, dict): if isinstance(body, dict):
self.goWithThisDict(body) self.goWithThisDict(body)

View file

@ -2,8 +2,8 @@
* Impression * Impression
************************************************************ ************************************************************
* Impression.settings : panneau de configuration * Impression.settings : panneau de configuration
* Impression.popup : popup * Impression.popup : popup
* Impression.AJAX : ajax * Impression.AJAX : ajax
*/ */
Impression = {}; Impression = {};
@ -17,7 +17,7 @@ Impression.settings = {};
//// images : images used for previewing //// images : images used for previewing
// //
Impression.settings.images = [ Impression.settings.images = [
"portrait_couleurs_agraphediagonale.png", "portrait_couleurs_agraphediagonale.png",
"portrait_couleurs_pasdagraphes.png", "portrait_couleurs_pasdagraphes.png",
"portrait_couleurs_uneagraphe.png", "portrait_couleurs_uneagraphe.png",
"portrait_couleurs_Deuxagraphes.png", "portrait_couleurs_Deuxagraphes.png",
@ -61,7 +61,7 @@ Impression.settings.reset = function () {
Impression.settings.update(); Impression.settings.update();
} }
Impression.settings.disableForm = function(bool) Impression.settings.disableForm = function(bool)
{ {
log("Set Disable Form : " + bool); log("Set Disable Form : " + bool);
var fields = this.theform.elements; var fields = this.theform.elements;
@ -74,9 +74,9 @@ Impression.settings.disableForm = function(bool)
// //
//// getValue : parse a field and store value in fielld.name //// getValue : parse a field and store value in fielld.name
// //
Impression.settings.getValue = function(field) Impression.settings.getValue = function(field)
{ {
if (field.value) if (field.value)
{ {
this[field.name] = field.value; this[field.name] = field.value;
log( field.name + " is now " + this[field.name]); log( field.name + " is now " + this[field.name]);
@ -95,7 +95,7 @@ Impression.settings.getCopies = function(field) {
this.copies = 1; this.copies = 1;
logError("Can't get copies"); logError("Can't get copies");
} }
else else
{ {
this.copies = parseInt(field.value); this.copies = parseInt(field.value);
} }
@ -114,7 +114,7 @@ Impression.settings.setValue = function(afield, avalue) {
//// setDisableField : set field disabled on/off //// setDisableField : set field disabled on/off
// //
Impression.settings.setDisableField = function( afield, isdisabled ) { Impression.settings.setDisableField = function( afield, isdisabled ) {
afield.disabled = isdisabled ; afield.disabled = isdisabled ;
} }
// //
@ -133,7 +133,7 @@ Impression.settings.update = function () {
this.getValue(this.theform.type_impression_couleur); this.getValue(this.theform.type_impression_couleur);
else else
this.getValue(this.theform.type_impression_nb); this.getValue(this.theform.type_impression_nb);
if (this.theform.disposition_recto.checked) if (this.theform.disposition_recto.checked)
this.getValue(this.theform.disposition_recto); this.getValue(this.theform.disposition_recto);
else if (this.theform.disposition_recto_verso.checked) else if (this.theform.disposition_recto_verso.checked)
@ -156,28 +156,28 @@ Impression.settings.update = function () {
} else { } else {
this.setDisableField(this.theform.agrafes, false); this.setDisableField(this.theform.agrafes, false);
} }
if (this.papier == "A4tr") if (this.papier == "A4tr")
{ {
this.theform.disposition_recto.checked = true; this.theform.disposition_recto.checked = true;
this.disableField(this.theform.disposition_recto); this.disableField(this.theform.disposition_recto);
this.disableField(this.theform.disposition_recto_verso); this.disableField(this.theform.disposition_recto_verso);
this.getValue(this.theform.disposition_recto); this.getValue(this.theform.disposition_recto);
} }
else else
{ {
this.setDisableField(this.theform.disposition_recto, false); this.setDisableField(this.theform.disposition_recto, false);
this.setDisableField(this.theform.disposition_recto_verso, false); this.setDisableField(this.theform.disposition_recto_verso, false);
} }
this.updatePreview(); this.updatePreview();
Impression.AJAX.recalcPrix(); Impression.AJAX.recalcPrix();
} }
// //
//// updatePreview : update preview with new value //// updatePreview : update preview with new value
// //
Impression.settings.updatePreview = function() Impression.settings.updatePreview = function()
{ {
var image_name = ""; var image_name = "";
if (this.papier == "A4tr") if (this.papier == "A4tr")
@ -197,23 +197,23 @@ Impression.popup = {};
Impression.popup.popupImpression = function(code, codeJ) { Impression.popup.popupImpression = function(code, codeJ) {
Popup.hide(); Popup.hide();
Popup.create({}, "Impression en cours...", Popup.create({}, "Impression en cours...",
DIV( DIV(
{"id":"printingPopupContent", "style":"background-image:url(./static/dialog-printer.png)"}, {"id":"printingPopupContent", "style":"background-image:url(./static/dialog-printer.png)"},
SPAN("code: "+code), SPAN("code: "+code),
SPAN("Batiment J: "+codeJ), SPAN("Batiment J: "+codeJ),
A({"href":"https://wiki.crans.org/VieCrans/ImpressionReseau", "class":"aide", "target":"_blank"}, "Comment récupérer mon impression ? "), A({"href":"https://wiki.crans.org/VieCrans/ImpressionReseau", "class":"aide", "target":"_blank"}, "Comment récupérer mon impression ? "),
A({"href":"index", "class":"aide", "style":"text-align:right;"}, "Nouvelle impression") A({"href":"index", "class":"aide", "style":"text-align:right;"}, "Nouvelle impression")
) )
); );
Popup.display(); Popup.display();
} }
Impression.popup.popupError = function(erreur) { Impression.popup.popupError = function(erreur) {
Popup.hide(); Popup.hide();
Popup.create({}, "Erreur", Popup.create({}, "Erreur",
DIV({"id":"printingPopupContent", "style":"background-image:url(./static/dialog-warning.png)"}, DIV({"id":"printingPopupContent", "style":"background-image:url(./static/dialog-warning.png)"},
SPAN(erreur), SPAN(erreur),
A({"href":"mailto:nounous@crans.org", "class":"crans_help aide"}, "Envoyer un rapport aux nounous"), A({"href":"mailto:nounous@crans.org", "class":"crans_help aide"}, "Envoyer un rapport aux nounous"),
Popup.closeLink({"class":"aide", "style":"text-align:right;"}, "Fermer"))); Popup.closeLink({"class":"aide", "style":"text-align:right;"}, "Fermer")));
@ -222,9 +222,9 @@ Impression.popup.popupError = function(erreur) {
Impression.popup.popupSolde = function(code) { Impression.popup.popupSolde = function(code) {
Popup.hide(); Popup.hide();
Popup.create({}, "Solde insuffisant", Popup.create({}, "Solde insuffisant",
DIV( DIV(
{"id":"printingPopupContent", "style":"background-image:url(./static/dialog-solde.png)"}, {"id":"printingPopupContent", "style":"background-image:url(./static/dialog-solde.png)"},
SPAN("pas assez de sous"), SPAN("pas assez de sous"),
A({"href":"https://wiki.crans.org/CransPratique/SoldeImpression", "class":"aide", "target":"_blank"}, "Comment recharger mon compte ? "), A({"href":"https://wiki.crans.org/CransPratique/SoldeImpression", "class":"aide", "target":"_blank"}, "Comment recharger mon compte ? "),
Popup.closeLink({"class":"aide", "style":"text-align:right;"}, "Fermer"))); Popup.closeLink({"class":"aide", "style":"text-align:right;"}, "Fermer")));
@ -233,9 +233,9 @@ Impression.popup.popupSolde = function(code) {
Impression.popup.popupCodes = function(codeList) { Impression.popup.popupCodes = function(codeList) {
Popup.hide(); Popup.hide();
Popup.create({}, "Codes de mes impressions", Popup.create({}, "Codes de mes impressions",
DIV( DIV(
{"id":"printingPopupContent", "style":"background-image:url(./static/dialog-lock.png)"}, {"id":"printingPopupContent", "style":"background-image:url(./static/dialog-lock.png)"},
SPAN("Mes codes"), SPAN("Mes codes"),
//UL({"size":"4", "style":"width:6em;; height:4em;padding:0;margin:0;list-style-type:none;overflow:auto;"}, map(function (code) {return LI({}, code);}, codeList)), //UL({"size":"4", "style":"width:6em;; height:4em;padding:0;margin:0;list-style-type:none;overflow:auto;"}, map(function (code) {return LI({}, code);}, codeList)),
SELECT({"size":"4", "style":"width:100%;"}, map(function (code) {return LI({}, code);}, codeList)), SELECT({"size":"4", "style":"width:100%;"}, map(function (code) {return LI({}, code);}, codeList)),
@ -249,7 +249,7 @@ Impression.popup.popupCodes = function(codeList) {
Impression.mesCodes Impression.mesCodes
*****************************/ *****************************/
Impression.mesCodes = {}; Impression.mesCodes = {};
Impression.mesCodes.getCodes = function () Impression.mesCodes.getCodes = function ()
{ {
Impression.AJAX.call('codeList', this.displayCodes ); Impression.AJAX.call('codeList', this.displayCodes );
} }
@ -268,17 +268,17 @@ Impression.mesCodes.displayCodes = function (result) {
*****************************/ *****************************/
Impression.AJAX = {}; Impression.AJAX = {};
Impression.AJAX.call = function(url,callback) { Impression.AJAX.call = function(url,callback) {
AJAX.call( url, callback, true); AJAX.call( url, callback, true);
} }
Impression.AJAX.modifPrix = function( text, wheel ) Impression.AJAX.modifPrix = function( text, wheel )
{ {
if (wheel) if (wheel)
{ {
var image = createDOM("IMG",{'src':'./static/indicator.gif'}); var image = createDOM("IMG",{'src':'./static/indicator.gif'});
} }
else else
{ {
var image = new DIV({}); var image = new DIV({});
} }
@ -299,7 +299,7 @@ Impression.AJAX.usefile = function(filename) {
this.call('useFile?fileName=' + filename,this.analysefini ); this.call('useFile?fileName=' + filename,this.analysefini );
} }
Impression.AJAX.analysefini = function(AJAXResp) Impression.AJAX.analysefini = function(AJAXResp)
{ {
logDebug('AJAX terminated (usefile)'); logDebug('AJAX terminated (usefile)');
if (AJAXResp.erreur) { if (AJAXResp.erreur) {
@ -314,7 +314,7 @@ Impression.AJAX.analysefini = function(AJAXResp)
} }
} }
Impression.AJAX.recalcPrix = function() Impression.AJAX.recalcPrix = function()
{ {
settings = Impression.settings; settings = Impression.settings;
var url = "changeSettings?copies=" + settings.copies var url = "changeSettings?copies=" + settings.copies
@ -334,7 +334,7 @@ Impression.AJAX.changePrix = function(AJAXResp)
Impression.settings.disableForm(true); Impression.settings.disableForm(true);
logWarning('Erreur distante : ' + AJAXResp.erreur); logWarning('Erreur distante : ' + AJAXResp.erreur);
} else { } else {
Impression.AJAX.modifPrix("Coût : " + AJAXResp.nouvPrix + "€", false); Impression.AJAX.modifPrix("Coût : " + AJAXResp.nouvPrix + "€", false);
} }
} }

View file

@ -2,7 +2,7 @@ Popup = {};
Popup.popupNode = null; Popup.popupNode = null;
Popup.visible = false; Popup.visible = false;
Popup.display = function() Popup.display = function()
{ {
if (this.popupNode == null) { if (this.popupNode == null) {
logError("Popup not created, cannot be displayed"); logError("Popup not created, cannot be displayed");
@ -10,11 +10,11 @@ Popup.display = function()
} }
appendChildNodes("pageContent", this.popupNode); appendChildNodes("pageContent", this.popupNode);
this.visible = true; this.visible = true;
// logDebug("popup visible"); // logDebug("popup visible");
} }
Popup.create = function(options, title_popup, content) { Popup.create = function(options, title_popup, content) {
var inPopup = DIV({"id":"__popupInDivId", "style":"background:white;margin:2px 5px;"}, content); var inPopup = DIV({"id":"__popupInDivId", "style":"background:white;margin:2px 5px;"}, content);
var outPopup = DIV({"id":"__popupOutDivId","style":"background:#AE0F3E;z-index:500;float:left;padding:0;min-width:300px;position:fixed;top:30%;left:30%;right:30%;"}, H1({"style":"font-size:1em;margin:0;text-align:center;color:white;"}, IMG({"src":"/static/images/WindowTitleLogo.png","alt":"icon", "style":"margin:0 5px;"}), title_popup), inPopup ); var outPopup = DIV({"id":"__popupOutDivId","style":"background:#AE0F3E;z-index:500;float:left;padding:0;min-width:300px;position:fixed;top:30%;left:30%;right:30%;"}, H1({"style":"font-size:1em;margin:0;text-align:center;color:white;"}, IMG({"src":"/static/images/WindowTitleLogo.png","alt":"icon", "style":"margin:0 5px;"}), title_popup), inPopup );
roundElement(outPopup); roundElement(outPopup);
logDebug("Popup \""+ title_popup +"\" created"); logDebug("Popup \""+ title_popup +"\" created");
@ -26,7 +26,7 @@ Popup.hide = function() {
removeElement(this.popupNode); removeElement(this.popupNode);
this.visible = false; this.visible = false;
} }
// logDebug("popup not visible"); // logDebug("popup not visible");
} }
Popup.closeLink = function(options, text_link) { Popup.closeLink = function(options, text_link) {
options["href"] = "#"; options["href"] = "#";

View file

@ -15,7 +15,7 @@ Crans.messages.setMessage('$errorMsg.replace("\'","\\\'")', 'errorMessage')
<div id="preview" onclick="Impression.settings.init();"></div> <div id="preview" onclick="Impression.settings.init();"></div>
<div class="clear prix_impression" id="prix_placeholder"></div> <div class="clear prix_impression" id="prix_placeholder"></div>
</div> </div>
<div id="rightColumn"> <div id="rightColumn">
<fieldset><legend>Type d'impression</legend> <fieldset><legend>Type d'impression</legend>
<label for="type_impression_couleur" class="labelRadio compact"> <label for="type_impression_couleur" class="labelRadio compact">
@ -26,9 +26,9 @@ Crans.messages.setMessage('$errorMsg.replace("\'","\\\'")', 'errorMessage')
Noir et blanc Noir et blanc
</label> </label>
</fieldset> </fieldset>
<fieldset><legend>Copies et papier</legend> <fieldset><legend>Copies et papier</legend>
<label for="papier" class="labelInput">Papier:</label> <label for="papier" class="labelInput">Papier:</label>
<select name="papier" id="papier" class="selectOne" onchange="Impression.settings.update(this);"> <select name="papier" id="papier" class="selectOne" onchange="Impression.settings.update(this);">
#for type_papier in $crans.impression.PAPIER_VALEURS_POSSIBLES #for type_papier in $crans.impression.PAPIER_VALEURS_POSSIBLES
@ -43,9 +43,9 @@ Crans.messages.setMessage('$errorMsg.replace("\'","\\\'")', 'errorMessage')
#end for #end for
</select> </select>
<br /> <br />
<label for="nb_copies" class="labelInput">Copies:</label> <label for="nb_copies" class="labelInput">Copies:</label>
<input onkeyup="Impression.settings.update(this);" type="text" name="nb_copies" id="nb_copies" class="inputText" size="10" maxlength="50" value="1" /> <input onkeyup="Impression.settings.update(this);" type="text" name="nb_copies" id="nb_copies" class="inputText" size="10" maxlength="50" value="1" />
</fieldset> </fieldset>
<fieldset><legend>Disposition</legend> <fieldset><legend>Disposition</legend>
@ -64,7 +64,7 @@ Crans.messages.setMessage('$errorMsg.replace("\'","\\\'")', 'errorMessage')
<a class="aide" href="http://wiki.crans.org/VieCrans/ImpressionReseau/Aide/Disposition">aide</a> <a class="aide" href="http://wiki.crans.org/VieCrans/ImpressionReseau/Aide/Disposition">aide</a>
</fieldset> </fieldset>
</div> </div>
<div class="clear bouttons"> <div class="clear bouttons">
<input type="reset" value="Reset" onclick="Impression.settings.reset();return false;" /> <input type="reset" value="Reset" onclick="Impression.settings.reset();return false;" />
<input type="button" value="Devis" onclick="window.open('devis')" /> <input type="button" value="Devis" onclick="window.open('devis')" />
@ -102,7 +102,7 @@ Crans.messages.setMessage('$errorMsg.replace("\'","\\\'")', 'errorMessage')
</script> </script>
</ul> </ul>
#if not $getVar('Erreur_imprimante',False) #if not $getVar('Erreur_imprimante',False)
#if not $getVar('fileName',False) #if not $getVar('fileName',False)
<div id="popupFichiers"> <div id="popupFichiers">
<h1>Impression - Choix fichier</h1> <h1>Impression - Choix fichier</h1>
@ -130,8 +130,8 @@ nounous</span> </p>
<h2>Envoyer un fichier</h2> <h2>Envoyer un fichier</h2>
<div> <div>
<input type="file" name="newFile" class="file" /> <input type="file" name="newFile" class="file" />
<input type="submit" name="submit" value="Envoyer" class="button"> <input type="submit" name="submit" value="Envoyer" class="button"/>
</div> </div>
</form> </form>
<div class="clear"></div> <div class="clear"></div>
</div> </div>
@ -150,7 +150,7 @@ nounous</span> </p>
Impression.settings.init(); Impression.settings.init();
//Impression..AJAX.updateSolde(); //Impression..AJAX.updateSolde();
Impression.AJAX.usefile('$fileName'); Impression.AJAX.usefile('$fileName');
Impression.settings.preloadAllImages(); Impression.settings.preloadAllImages();
//--> //-->
</script> </script>
#else #else
@ -162,7 +162,7 @@ nounous</span> </p>
//--> //-->
</script> </script>
#end if #end if
#else #else
## desactivation de l'interface si l'imprimant a un probleme ## desactivation de l'interface si l'imprimant a un probleme
<script type="text/javascript"> <script type="text/javascript">
<!-- <!--

View file

@ -383,7 +383,6 @@ class impression:
# Pour spécifier la version du language postscript utilisé par pdftops # Pour spécifier la version du language postscript utilisé par pdftops
# options += ' -o pdf-level3' # options += ' -o pdf-level3'
# Pour donner le titre de l'impression # Pour donner le titre de l'impression
options += " -T \"%s\"" % self.nom_job.replace("\"","\\\"") options += " -T \"%s\"" % self.nom_job.replace("\"","\\\"")