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

View file

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

View file

@ -2,8 +2,8 @@
* Impression
************************************************************
* Impression.settings : panneau de configuration
* Impression.popup : popup
* Impression.AJAX : ajax
* Impression.popup : popup
* Impression.AJAX : ajax
*/
Impression = {};
@ -17,7 +17,7 @@ Impression.settings = {};
//// images : images used for previewing
//
Impression.settings.images = [
"portrait_couleurs_agraphediagonale.png",
"portrait_couleurs_agraphediagonale.png",
"portrait_couleurs_pasdagraphes.png",
"portrait_couleurs_uneagraphe.png",
"portrait_couleurs_Deuxagraphes.png",
@ -61,7 +61,7 @@ Impression.settings.reset = function () {
Impression.settings.update();
}
Impression.settings.disableForm = function(bool)
Impression.settings.disableForm = function(bool)
{
log("Set Disable Form : " + bool);
var fields = this.theform.elements;
@ -74,9 +74,9 @@ Impression.settings.disableForm = function(bool)
//
//// 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;
log( field.name + " is now " + this[field.name]);
@ -95,7 +95,7 @@ Impression.settings.getCopies = function(field) {
this.copies = 1;
logError("Can't get copies");
}
else
else
{
this.copies = parseInt(field.value);
}
@ -114,7 +114,7 @@ Impression.settings.setValue = function(afield, avalue) {
//// setDisableField : set field disabled on/off
//
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);
else
this.getValue(this.theform.type_impression_nb);
if (this.theform.disposition_recto.checked)
this.getValue(this.theform.disposition_recto);
else if (this.theform.disposition_recto_verso.checked)
@ -156,28 +156,28 @@ Impression.settings.update = function () {
} else {
this.setDisableField(this.theform.agrafes, false);
}
if (this.papier == "A4tr")
if (this.papier == "A4tr")
{
this.theform.disposition_recto.checked = true;
this.disableField(this.theform.disposition_recto);
this.disableField(this.theform.disposition_recto_verso);
this.getValue(this.theform.disposition_recto);
}
else
else
{
this.setDisableField(this.theform.disposition_recto, false);
this.setDisableField(this.theform.disposition_recto_verso, false);
this.setDisableField(this.theform.disposition_recto, false);
this.setDisableField(this.theform.disposition_recto_verso, false);
}
this.updatePreview();
Impression.AJAX.recalcPrix();
}
//
//// updatePreview : update preview with new value
//
Impression.settings.updatePreview = function()
Impression.settings.updatePreview = function()
{
var image_name = "";
if (this.papier == "A4tr")
@ -197,23 +197,23 @@ Impression.popup = {};
Impression.popup.popupImpression = function(code, codeJ) {
Popup.hide();
Popup.create({}, "Impression en cours...",
Popup.create({}, "Impression en cours...",
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("Batiment J: "+codeJ),
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")
)
);
Popup.display();
}
Impression.popup.popupError = function(erreur) {
Popup.hide();
Popup.create({}, "Erreur",
DIV({"id":"printingPopupContent", "style":"background-image:url(./static/dialog-warning.png)"},
Popup.create({}, "Erreur",
DIV({"id":"printingPopupContent", "style":"background-image:url(./static/dialog-warning.png)"},
SPAN(erreur),
A({"href":"mailto:nounous@crans.org", "class":"crans_help aide"}, "Envoyer un rapport aux nounous"),
Popup.closeLink({"class":"aide", "style":"text-align:right;"}, "Fermer")));
@ -222,9 +222,9 @@ Impression.popup.popupError = function(erreur) {
Impression.popup.popupSolde = function(code) {
Popup.hide();
Popup.create({}, "Solde insuffisant",
Popup.create({}, "Solde insuffisant",
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"),
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")));
@ -233,9 +233,9 @@ Impression.popup.popupSolde = function(code) {
Impression.popup.popupCodes = function(codeList) {
Popup.hide();
Popup.create({}, "Codes de mes impressions",
Popup.create({}, "Codes de mes impressions",
DIV(
{"id":"printingPopupContent", "style":"background-image:url(./static/dialog-lock.png)"},
{"id":"printingPopupContent", "style":"background-image:url(./static/dialog-lock.png)"},
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)),
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.getCodes = function ()
Impression.mesCodes.getCodes = function ()
{
Impression.AJAX.call('codeList', this.displayCodes );
}
@ -268,17 +268,17 @@ Impression.mesCodes.displayCodes = function (result) {
*****************************/
Impression.AJAX = {};
Impression.AJAX.call = function(url,callback) {
Impression.AJAX.call = function(url,callback) {
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'});
}
else
}
else
{
var image = new DIV({});
}
@ -299,7 +299,7 @@ Impression.AJAX.usefile = function(filename) {
this.call('useFile?fileName=' + filename,this.analysefini );
}
Impression.AJAX.analysefini = function(AJAXResp)
Impression.AJAX.analysefini = function(AJAXResp)
{
logDebug('AJAX terminated (usefile)');
if (AJAXResp.erreur) {
@ -314,7 +314,7 @@ Impression.AJAX.analysefini = function(AJAXResp)
}
}
Impression.AJAX.recalcPrix = function()
Impression.AJAX.recalcPrix = function()
{
settings = Impression.settings;
var url = "changeSettings?copies=" + settings.copies
@ -334,7 +334,7 @@ Impression.AJAX.changePrix = function(AJAXResp)
Impression.settings.disableForm(true);
logWarning('Erreur distante : ' + AJAXResp.erreur);
} 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.visible = false;
Popup.display = function()
Popup.display = function()
{
if (this.popupNode == null) {
logError("Popup not created, cannot be displayed");
@ -10,11 +10,11 @@ Popup.display = function()
}
appendChildNodes("pageContent", this.popupNode);
this.visible = true;
// logDebug("popup visible");
// logDebug("popup visible");
}
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 );
roundElement(outPopup);
logDebug("Popup \""+ title_popup +"\" created");
@ -26,7 +26,7 @@ Popup.hide = function() {
removeElement(this.popupNode);
this.visible = false;
}
// logDebug("popup not visible");
// logDebug("popup not visible");
}
Popup.closeLink = function(options, text_link) {
options["href"] = "#";

View file

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

View file

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