Ajout des modules initiaux

darcs-hash:20070124114812-f46e9-171ef12f1e1b89ae005adf4aab6f6535fb9289e6.gz
This commit is contained in:
gdetrez 2007-01-24 12:48:12 +01:00
parent 8713311bc1
commit ed3ab40ccd
80 changed files with 4852 additions and 5 deletions

View file

@ -11,11 +11,6 @@ crans.modules.dir = "/usr/scripts/intranet/modules/"
# Now we can work on our filter as with the standard filters
templatesEngine.on = True
[/digicode]
crans.droits="Imprimeur"
[/gestionFactures]
crans.droits="Imprimeur"
[/impression]
crans.activate = True
crans.activate.errorMsg = u"Plus d'encre ! Le fournisseur s'est trompé dans la commande."

View file

@ -0,0 +1,81 @@
#! /usr/bin/env python
import cherrypy, tempfile, shutil, os
import crans.impression
import crans.impression.digicode
import crans.cp
from ClassesIntranet.ModuleBase import ModuleBase
class main(ModuleBase):
_droits = ["Imprimeur"]
def category(self):
return "Imprimeur"
def title(self):
return "Digicode"
##########################
# affichage
##########################
#
# methode qui affiche la template
#
def index(self, submit = None, fileList = None, newFile = None ):
return {'template':'digicode',
'values':{},
'stylesheets':['digicode.css'],
'scripts':['digicode.js', 'popup.js'],
}
index.exposed = True
##########################
# AJAX
##########################
#
# methode qui renvoie la liste des codes
#
def codeList(self):
try:
listeBrute = crans.impression.digicode.list_code()
liste_formatee = []
for aCode in listeBrute:
age = aCode[1]
age_jours = (age/3600)/24
age_heures = (age/3600) - age_jours*24
age_minutes = (age/60) - (age/3600)*60
if age_jours > 0:
age_string = "%sj %sh %smin" % (str(age_jours), str(age_heures), str( age_minutes ))
elif age_heures > 0:
age_string = "%sh %smin" % (str(age_heures), str( age_minutes ))
else:
age_string = "%smin" % (str( age_minutes ))
liste_formatee.append({'code':aCode[0], 'age':age_string, 'desc':aCode[2]})
return {'codes': liste_formatee}
except Exception, e:
crans.cp.log('erreur lors de la creation de la liste de codes :' + str(e), 'DIGICODE', 1)
return {'erreur':str(e)}
codeList.exposed= True
#
# methode qui cree un code
#
def createCode(self, code=None, adherent=''):
try:
if adherent == '':
adherent = cherrypy.session['uid']
if code:
try:
int(code)
if code.__len__() != 6:
raise
except:
return {'formatErreur':1}
code = crans.impression.digicode.save_code(code, adherent)
else:
code = crans.impression.digicode.gen_code(adherent)
crans.cp.log("code cree : %s" % code, 'DIGICODE')
return {'code': code, "age" : "new", "desc":adherent}
except Exception, e:
crans.cp.log("erreur lors de la creation de code : " + str(e), 'DIGICODE', 1)
return {'erreur':str(e)}
createCode.exposed= True

View file

@ -0,0 +1,85 @@
/*************************************************************
..
.... ............ ........
. ....... . .... ..
. ... .. .. .. .. ..... . ..
.. .. ....@@@. .. . ........ .
.. . .. ..@.@@..@@. .@@@@@@@ @@@@@@. ....
.@@@@. .@@@@. .@@@@..@@.@@..@@@..@@@..@@@@.... ....
@@@@... .@@@.. @@ @@ .@..@@..@@...@@@. .@@@@@. ..
.@@@.. . @@@. @@.@@..@@.@@..@@@ @@ .@@@@@@.. .....
...@@@.... @@@ .@@.......... ........ ..... ..
. ..@@@@.. . .@@@@. .. ....... . .............
. .. .... .. .. . ... ....
. . .... ............. .. ...
.. .. ... ........ ... ...
................................
==============================================================
digicode.css - Intranet Style
STYLE PAGE DU DIGICODE
Copyright (c) 2006 by www.crans.org
**************************************************************/
#codesTable {
width:60%;
border:thin black solid;
float:left;
}
#codesTable thead {
color:gray;
}
#codesTable .code {
border-right:thin gray solid;
width:70%;
}
#codesTable tbody .age {
text-align:right;
}
#codesTable td,
#codesTable th {
margin:0;
padding:2px 5px;
}
#codesTable tbody td {
border-top:thin gray solid;
}
#codesTable thead th {
border-top:none;
}
div#addCodeBox {
float: right;
border:thin black solid;
padding:10px;
margin:0 5%;
width:25%;
}
div#addCodeBox h1 {
font-size:1.1em;
margin:2px 10px 20px 10px;
text-align:center;
}
div#addCodeBox form {
}
div#addCodeBox form input,
div#addCodeBox form button {
margin:3px;
}
form input.textinput {
border: thin gray solid;
}

View file

@ -0,0 +1,170 @@
/* ************************************************************
* Digicode
************************************************************
* Digicode.init : initialisation de la page
* Digicode.makeCode : creation de codes
* Digicode.codelist : liste des codes
* Digicode.AJAX : ajax
*/
Digicode = {};
/*****************************
Digicode.init
*****************************/
Digicode.init = function()
{
// afficher le tableau codelist
appendChildNodes("globalDiv", Digicode.codelist.create());
// recuperer la liste des codes
this.codelist.load();
// afficher le formulaire de creation de code
appendChildNodes("globalDiv", DIV({"id":"addCodeBox"}));
Digicode.makeCode.displayForm();
}
/*****************************
Digicode.makeCode
*****************************/
Digicode.makeCode = {}
Digicode.makeCode.displayForm = function()
{
var myForm = FORM({'id':'createCodeForm', 'name':'createCodeForm','onsubmit':"Digicode.makeCode.createCode(document.createCodeForm.newCodeLogin.value, document.createCodeForm.newCode.value); return false;", 'style':'display: none;'},
LABEL({'for':'newCodeLogin'}, "Login adhérent :"),
INPUT({"name":"newCodeLogin", "size":"10", "maxlength":"20", "class":"textinput"}),
BR(),
LABEL({'for':'newCode'}, "Code :"),
INPUT({"name":"newCode", "size":"6", "maxlength":"6", "class":"textinput"}),
BUTTON({"type":"submit","onclick":"Digicode.makeCode.createCode(document.createCodeForm.newCodeLogin.value, document.createCodeForm.newCode.value)", "style":"float:right;"},"Créer code"),
BUTTON({"type":"button","onclick":"Digicode.makeCode.createCode(document.createCodeForm.newCodeLogin.value)", "style":"float:right;"},"Code aléatoire")
);
replaceChildNodes("addCodeBox", H1({},"Nouveau code"), myForm );
appear(myForm);
}
Digicode.makeCode.restoreForm = function()
{
try
{
removeElement("newCodeDisplay");
removeElement("loading");
} catch (error){}
appear("createCodeForm");
}
Digicode.makeCode.disableForm = function()
{
try
{
var form = getElement("createCodeForm");
var elts = form.elements;
for (i=0 ; i < elts.length ; i++)
elts[i].disabled = true;
}
catch (error){}
}
Digicode.makeCode.createCode = function(login, code)
{
var image = createDOM("IMG",{'style':'margin-right:2px;float:right;','src':'/static/images/indicator.gif'});
appendChildNodes("addCodeBox", DIV({'id':"loading",'style':'display:none;max-height:1em;float:left;'},image,"Loading"));
this.disableForm();
//removeElement("createCodeForm");
appear("loading");
if (code)
Digicode.AJAX.call("createCode?code="+code + "&adherent=" + login, this.handleNewCode);
else
Digicode.AJAX.call("createCode?adherent=" + login, this.handleNewCode);
}
Digicode.makeCode.handleNewCode = function(res)
{
if (res.code)
{
replaceChildNodes("addCodeBox",
H1({}, "Code créé"),
DIV({'id':"newCodeDisplay",
'style':'display:none;font-size:2em;maring:1em;font-weight:bold;text-align:center;',
'onclick':"Digicode.makeCode.displayForm();"},res.code));
appear("newCodeDisplay");
//removeElement("loading");
Digicode.codelist.addCode(res);
} else if (res.erreur) {
logError("Erreur distante : " + res.erreur);
alert("Erreur sur le serveur, le code est peut-être déjà pris.")
Digicode.makeCode.displayForm();
} else if (res.formatErreur) {
alert("Ceci n'est pas un code valide");
Digicode.makeCode.displayForm();
}
}
/*****************************
Digicode.codelist
*****************************/
Digicode.codelist = {};
Digicode.codelist.create = function ()
{
var thead = createDOM("thead", {},
createDOM("th", {'class':'code'}, "Code" ),
createDOM("th", {'class':'age'}, "Age")
);
var tbody = createDOM("tbody", {"id":"codeList"});
return TABLE({"id":"codesTable", "cellspacing":"0"}, thead, tbody)
}
Digicode.codelist.load = function()
{
Digicode.AJAX.call("codeList", Digicode.codelist.displayCodes);
}
Digicode.codelist.displayCodes = function(result)
{
if (result.codes)
replaceChildNodes('codeList',map(Digicode.codelist.newCodeTrNodeFromDict,result.codes));
else if (result.erreur)
logError("Erreur distante : " + result.erreur);
}
Digicode.codelist.newCodeTrNodeFromDict = function (aDict, style)
{
if (style) {
var aRow = createDOM("TR", {'id':'code'+aDict.code,"style":style});
} else
var aRow = createDOM("TR", {'id':'code'+aDict.code});
appendChildNodes(aRow, createDOM("TD", {'class':'code'}, aDict.code, SPAN({'style':'color:gray;margin-left:2em;'}, aDict.desc ) ) );
appendChildNodes(aRow, createDOM("TD", {'class':'age'}, aDict.age) );
return aRow;
}
Digicode.codelist.addCode = function (aDict)
{
var newLine = this.newCodeTrNodeFromDict(aDict);
appendChildNodes("codeList", newLine);
pulsate(newLine);
}
/*****************************
Digicode.AJAX
*****************************/
Digicode.AJAX = {}
Digicode.AJAX.call = function(page, callBack) {
logDebug("calling AJAX : " + page);
var e = loadJSONDoc(page);
e.addCallback(callBack);
e.addErrback(this.errorHandler);
}
Digicode.AJAX.errorHandler = function(d) {
//Digicode.AJAX..modifPrix("Erreur", false);
logError("AJAX Error: " + d);
}
setInterval(Digicode.codelist.load, 30000);

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

View file

@ -0,0 +1,14 @@
#import crans.impression
<div id="globalDiv">
<h1>Gestion des codes pour le local impression</h1>
</div>
<script type="text/javascript">
<!--
Digicode.init();
//-->
</script>
<noscript>
<p>Cette page utilise javascript. Elle n'est pas support&eacute;e par votre
navigateur.</p>
</noscript>

100
intranet/modules/factures/main.py Executable file
View file

@ -0,0 +1,100 @@
#! /usr/bin/env python
# -*- coding: iso-8859-15 -*-
# ##################################################################################################### #
# Factures
# ##################################################################################################### #
# Description:
# Affiche la liste des factures et l'historique de débits/crédits de l'adhérent.
# Informations:
#
# Pages:
# index:liste des factures
# historique: historique des débits/crédits
#
# ##################################################################################################### #
import cherrypy, sys, os, datetime
from ClassesIntranet.ModuleBase import ModuleBase
class main(ModuleBase):
def title(self):
return "Factures"
def icon(self):
return "icon.png"
def index(self, message = '', error = ''):
adh = cherrypy.session['LDAP'].search('uid=' + cherrypy.session['uid'])['adherent'][0]
t = {}
t['message'] = message
t['error'] = error
############## liste des factures ##############
listeFactures = []
for f in adh.factures():
facture = {}
facture['no'] = f.numero()
facture['intitule'] = f.articles()[0]['designation']
facture['details'] = [
{
'intitule':art['designation'],
'quantite':art['nombre'],
'prixUnitaire':art['pu'],
'prixTotal':art['pu']*art['nombre'],
} for art in f.articles()]
facture['montant'] = f.total()
facture['paypal'] = f.urlPaypal(useSandbox = cherrypy.config.get("paypal.useSandbox", False),
businessMail = cherrypy.config.get("paypal.businessAdress", "paypal@crans.org"),
return_page = "https://intranet.crans.org/monCompte/paypalReturn",
cancel_return_page = "https://intranet.crans.org/monCompte/paypalCancel",
)
facture['payee'] = f.recuPaiement()
listeFactures.append(facture)
t['listeFactures'] = listeFactures
return {
'template' :'factures',
'values' :t,
'stylesheets' :['cransFactures.css'],
'scripts' :[],
}
index.exposed = True
def historique(self):
adh = cherrypy.session['LDAP'].search('uid=' + cherrypy.session['uid'])['adherent'][0]
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:
aLine = {}
aLine["date"] = anItem.split(u",")[0]
aLine["type"] = anItem.split(u' : ',2)[1].split(u' ')[0]
aLine["montant"] = anItem.split(u' : ',2)[1].split(u' ')[1]
try:
aLine["intitule"] = anItem.split(u'[')[1].split(u']')[0]
except Exception:
aLine["intitule"] = ""
histLst.append(aLine)
return {
'template' :'factures-historique',
'values' :{'liste':lst, 'historic_items':histLst},
'stylesheets' :['cransFactures.css'],
'scripts' :[],
}
historique.exposed = True
def delFacture(self, no):
try:
# trrouver la factures
fact = cherrypy.session['LDAP'].search('fid=' + no, 'w')['facture'][0]
#verifier qu'elle appartient bien a l'adherent
if not fact.proprietaire().mail() == cherrypy.session['uid']:
raise Exception, "Impossible de supprimer cette facture"
# la supprimer
fact.delete()
except Exception, e:
cherrypy.log(str(e), "FACTURES", 1)
return self.index()
delFacture.exposed = True

View file

@ -0,0 +1,205 @@
/********************************************
* <!-- disposition générale -->
********************************************/
#globalDiv {
//padding-left:20%;
position: relative;
}
ul#actionMenu {
list-style-type:none;
width:18%;
padding:0;
float:left;
}
h1 {
font-size:1.4em;
margin:2px;
}
td, tr {
margin:0;
}
#factureListDiv {
padding:5px;
background:#fad163;
float:left;
width:75%;
}
#factureListDiv table#listeFactures {
padding:0;
width:100%;
}
.factureRow {
margin:2px;
position:relative;
}
.help_text {
background:#fff7D7;
font-weight:normal;
padding:10px 20px;
}
.factureRow .factureSummary {
background:#fff7D7;
height:30px;
font-weight:bold;
padding:10px 20px;
}
.factureRow .factureSummary span.intitule {
float:left;
}
.factureRow .factureSummary span.montant {
float:right;
text-align:right;
}
.tdNoFactures {
text-align:center;
font-size:1.2em;
background-color:#fff7D7;
color:#666;
margin:0;
padding:5px;
}
.facturePayee {
}
.factureNonPayee .factureSummary {
color:red;
}
.actions {
display:block;
float:right;
font-size:0.9em;
font-weight:normal;
}
.actions a {
margin:2px 10px;
}
/********************************************
* <!-- factures - details -->
********************************************/
table.factureDetails {
background: #fff7D7 url(fondFacturesDetails.png) repeat-x top;
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;
}
/********************************************
* <!-- factures - divers -->
********************************************/
.note {
display:block;
font-size:small;
margin:3px;
font-weight:normal;
}
.note {
color:#666
}
.linkToggle {
display:block;
float:left;
height:15px;
width:15px;
background:transparent url(fl.png) top left;
margin-right:1px;
}
/********************************************
* <!-- factures - historique -->
********************************************/
table#historique_sous {
width:100%;
}
table#historique_sous td {
background:#fff7D7;
padding:5px;
text-align:center;
border-top:2px #fad163 solid;
}
table#historique_sous th {
background:#fff7D7;
padding:5px;
text-decoration:underline;
}
/********************************************
* <!-- factures - recherche -->
********************************************/
form.search {
display:block;
border: thin black solid;
padding:.2em 1em;
float:left;
//position:absolute;
width:18%;
//top:0;
//left:0;
margin:0 1%;
}
form.search input {
max-width:95%;
margin:.3em;
float:left;
border: thin gray solid;
}
form.search label {
padding-top:7px;
display:block;
width:4em;
float:left;
clear:left;
font-weight:bold;
}
form.search h3 {
margin:.2em 0;
}
form.search input.button {
margin:.5em;
text-align:center;
clear:left;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

View file

@ -0,0 +1,45 @@
<div id="messagePlaceHolder"></div>
<div id="globalDiv" onclick="setMessage();">
<ul id="actionMenu">
<li><a href="index">Mes factures PayPal</a></li>
<li><a href="historique">Historique des transactions</a></li>
</ul>
<div id="factureListDiv">
<h1>Historique</h1>
<div style="overflow:auto;">
<table id="historique_sous" cellspacing="0">
<tr>
<th>Date</th>
<th>Intitul&eacute;</th>
<th>D&eacute;bit</th>
<th>Cr&eacute;dit</th>
</tr>
#for anItem in $historic_items
<tr>
<td>$anItem.date</td>
<td>$anItem.intitule</td>
#if $anItem.type=="debit"
<td>$anItem.montant</td>
#else
<td>&nbsp;<!-- evite que opera fasse des trucs bizarres... --></td>
#end if
#if $anItem.type=="credit"
<td>$anItem.montant</td>
#else
<td>&nbsp;<!-- evite que opera fasse des trucs bizarres... --></td>
#end if
</tr>
#end for
#if $historic_items == []
<tr><td colspan="4" style="color:gray;">
AUCUNE TRANSACTION ENREGISTR&Eacute;E
</td></tr>
#end if
</table>
</div>
<!-- ********************** Menu ********************** -->
</div>
</div>

View file

@ -0,0 +1,107 @@
<div id="messagePlaceHolder"></div>
#if $message != ''
<script type="text/javascript">setMessage('$message.replace("\'","\\\'")')</script>
#end if
#if $error != ''
<script type="text/javascript">setMessage('$error.replace("\'","\\\'")', 'errorMessage')</script>
#end if
<script type="text/javascript">
function showDetail(id){
slideDown(id, {duration:0.4});
var element = document.getElementById("togglelink" + id);
element.onclick=null;
element.style.backgroundPosition='bottom left';
setTimeout("var element = document.getElementById(\'togglelink" + id + "\');element.onclick=function () {hideDetail(\'" + id + "\'); return false;};",450);
return false;
}
function hideDetail(id){
slideUp(id, {duration:0.4});
var element = document.getElementById("togglelink" + id);
element.onclick=null;
element.style.backgroundPosition="top left";
setTimeout("var element = document.getElementById(\'togglelink" + id + "\');element.onclick=function () {showDetail(\'" + id + "\'); return false;};",450);
return false;
}
</script>
<div id="globalDiv">
<ul id="actionMenu">
<li><a href="index">Mes factures PayPal</a></li>
<li><a href="historique">Historique des transactions</a></li>
</ul>
<div id="factureListDiv">
<h1>Mes factures PayPal</h1>
<!-- <table id="listeFactures" cellspacing="0" border="0"> -->
#for f in $listeFactures
#if $f.payee
<div class="factureRow facturePayee">
#else
<div class="factureRow factureNonPayee">
#end if
<div class="factureSummary">
<span class="intitule">
#if $f.details.__len__() > 1
<a href="#" class="linkToggle" id="togglelinkfacture$f.no" onclick="showDetail('facture$f.no'); return false;"></a>
#end if
$f.intitule
#if not $f.payee
(non pay&eacute;e)
#end if
</span>
<span class="montant">
$f.montant&nbsp;&euro;
</span>
<span class="note" style="float:left;clear: left;">Cr&eacute;e le -</span>
#if not $f.payee
<span class="actions">
<a href="delFacture?no=$f.no">Annuler</a>
<a href="$f.paypal">Payer avec PayPal</a>
</span>
#else
<span class="note" style="float:right;clear:right;">Pay&eacute;e</span>
#end if
</div>
#if $f.details.__len__() > 1
<div id="facture$f.no" style="display:none;">
<table cellspacing="0" border="0" class="factureDetails">
<tr>
<th style="width:80%">Description</th>
<th>Prix unitaire</th>
<th>Quantit&eacute;</th>
<th>total</th>
</tr>
#for unDetail in $f.details
<tr>
<td>$unDetail.intitule</td>
<td>$unDetail.prixUnitaire&nbsp;&euro;</td>
<td>$unDetail.quantite</td>
<td>$unDetail.prixTotal&nbsp;&euro;</td>
</tr>
#end for
<tr>
<td colspan="3" class="tdTotalDetailIntitule">
Total
</td>
<td class="tdTotalDetail">$f.montant&nbsp;&euro;</td>
</tr>
</table>
</div>
</div>
#end if
#end for
#if $listeFactures == []
<div class="factureRow tdNoFactures">
AUCUNE TRANSACTION PAYPAL ENREGISTR&Eacute;E
</div>
#end if
</div>
</div>

View file

@ -0,0 +1,140 @@
#! /usr/bin/env python
# -*- coding: iso-8859-15 -*-
# ##################################################################################################### #
# Factures (gestion)
# ##################################################################################################### #
# Description:
# Permet de chercher dans les facture, d'en créditer et d'en supprimer
# Informations:
#
# Pages:
# index:afiche le formulaire et les factures
#
# ##################################################################################################### #
import cherrypy, sys, os, datetime
import crans.cp
from ClassesIntranet.ModuleBase import ModuleBase
class main(ModuleBase):
_droits = ["Imprimeur"]
def title(self):
return "Gestion factures"
def category(self):
return "Imprimeur"
def index(self, message = '', erreur = ''):
if cherrypy.session.has_key('gestion_factures-current_search'):
del cherrypy.session['gestion_factures-current_search']
return self.displayTemplate()
index.exposed = True
def search(self, fid=None, uid=None, aid=None):
cherrypy.session['gestion_factures-current_search'] = {
"fid":fid,
"uid":uid,
"aid":aid,
}
return self.displayTemplate()
search.exposed = True
def displayTemplate(self, message = '', erreur = ''):
t = {}
t['message'] = message
t['error'] = erreur
if cherrypy.session.has_key('gestion_factures-current_search'):
fid = cherrypy.session['gestion_factures-current_search']['fid']
uid = cherrypy.session['gestion_factures-current_search']['uid']
aid = cherrypy.session['gestion_factures-current_search']['aid']
t['listeFactures'] = self.buildInvoiceList(
fid = fid,
uid = uid,
aid = aid,
)
else:
fid = ""
uid = ""
aid = ""
t["form"] = []
t["form"]+= [{'name':'fid', 'label':'fid', 'value':fid}]
t["form"]+= [{'name':'uid', 'label':'login', 'value':uid}]
t["form"]+= [{'name':'aid', 'label':'aid', 'value':aid}]
return {
'template' :'factures-gestion',
'values' :t,
'stylesheets' :['cransFactures.css'],
}
def buildInvoiceList(self, fid=None, uid=None, aid=None):
############## liste des factures ##############
if fid:
search_string = "fid=%s" % str(fid)
liste_factures_ldap = cherrypy.session['LDAP'].search(search_string)['facture']
elif uid:
search_string = "uid=%s" % str(uid)
try:
liste_factures_ldap = cherrypy.session['LDAP'].search(search_string)['adherent'][0].factures()
except:
liste_factures_ldap = []
elif aid:
search_string = "aid=%s" % str(aid)
try:
liste_factures_ldap = cherrypy.session['LDAP'].search(search_string)['adherent'][0].factures()
except:
liste_factures_ldap = []
else:
return []
liste_factures_affichees = []
for f in liste_factures_ldap:
try:
facture = {}
facture['no'] = f.numero()
facture['adherent'] = f.proprietaire().mail()
facture['montant'] = f.total()
facture['payee'] = f.recuPaiement()
facture['intitule'] = f.articles()[0]['designation']
facture['details'] = [
{
'intitule':art['designation'],
'quantite':art['nombre'],
'prixUnitaire':art['pu'],
'prixTotal':art['pu']*art['nombre'],
} for art in f.articles()]
liste_factures_affichees.append(facture)
except:
crans.cp.log("Facture non affichable : fid=%s" % str(f.numero()), "GESTION FACTURES", 1)
return liste_factures_affichees
def delFacture(self, fid):
try:
# trrouver la factures
fact = cherrypy.session['LDAP'].search('fid=' + fid, 'w')['facture'][0]
# la supprimer
fact.delete()
except Exception, e:
crans.cp.log(unicode(e), "GESTION FACTURES", 1)
return self.index(erreur=u"Probleme lors de la suppression")
crans.cp.log(u"Facture supprimee [fid=%s]" % fid, "GESTION FACTURES")
return self.displayTemplate(message=u"Facture suprimée")
delFacture.exposed = True
def crediteFacture(self, fid):
try:
# trrouver la factures
fact = cherrypy.session['LDAP'].search('fid=' + fid, 'w')['facture'][0]
# la supprimer
fact.recuPaiement(cherrypy.session['uid'])
fact.save()
except Exception, e:
crans.cp.log("pb crédit", "GESTION FACTURES", 1)
return self.index(erreur=u"Problème lors du crédit")
crans.cp.log("Facture creditee [fid=%s]" % fid, "GESTION FACTURES")
return self.displayTemplate(message=u"Facture créditée")
crediteFacture.exposed = True

View file

@ -0,0 +1,205 @@
/********************************************
* <!-- disposition générale -->
********************************************/
#globalDiv {
//padding-left:20%;
position: relative;
}
ul#actionMenu {
list-style-type:none;
width:18%;
padding:0;
float:left;
}
h1 {
font-size:1.4em;
margin:2px;
}
td, tr {
margin:0;
}
#factureListDiv {
padding:5px;
background:#fad163;
float:left;
width:75%;
}
#factureListDiv table#listeFactures {
padding:0;
width:100%;
}
.factureRow {
margin:2px;
position:relative;
}
.help_text {
background:#fff7D7;
font-weight:normal;
padding:10px 20px;
}
.factureRow .factureSummary {
background:#fff7D7;
height:30px;
font-weight:bold;
padding:10px 20px;
}
.factureRow .factureSummary span.intitule {
float:left;
}
.factureRow .factureSummary span.montant {
float:right;
text-align:right;
}
.tdNoFactures {
text-align:center;
font-size:1.2em;
background-color:#fff7D7;
color:#666;
margin:0;
padding:5px;
}
.facturePayee {
}
.factureNonPayee .factureSummary {
color:red;
}
.actions {
display:block;
float:right;
font-size:0.9em;
font-weight:normal;
}
.actions a {
margin:2px 10px;
}
/********************************************
* <!-- factures - details -->
********************************************/
table.factureDetails {
background: #fff7D7 url(fondFacturesDetails.png) repeat-x top;
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;
}
/********************************************
* <!-- factures - divers -->
********************************************/
.note {
display:block;
font-size:small;
margin:3px;
font-weight:normal;
}
.note {
color:#666
}
.linkToggle {
display:block;
float:left;
height:15px;
width:15px;
background:transparent url(fl.png) top left;
margin-right:1px;
}
/********************************************
* <!-- factures - historique -->
********************************************/
table#historique_sous {
width:100%;
}
table#historique_sous td {
background:#fff7D7;
padding:5px;
text-align:center;
border-top:2px #fad163 solid;
}
table#historique_sous th {
background:#fff7D7;
padding:5px;
text-decoration:underline;
}
/********************************************
* <!-- factures - recherche -->
********************************************/
form.search {
display:block;
border: thin black solid;
padding:.2em 1em;
float:left;
//position:absolute;
width:18%;
//top:0;
//left:0;
margin:0 1%;
}
form.search input {
max-width:95%;
margin:.3em;
float:left;
border: thin gray solid;
}
form.search label {
padding-top:7px;
display:block;
width:4em;
float:left;
clear:left;
font-weight:bold;
}
form.search h3 {
margin:.2em 0;
}
form.search input.button {
margin:.5em;
text-align:center;
clear:left;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

View file

@ -0,0 +1,45 @@
<div id="messagePlaceHolder"></div>
<div id="globalDiv" onclick="setMessage();">
<ul id="actionMenu">
<li><a href="index">Mes factures PayPal</a></li>
<li><a href="historique">Historique des transactions</a></li>
</ul>
<div id="factureListDiv">
<h1>Historique</h1>
<div style="overflow:auto;">
<table id="historique_sous" cellspacing="0">
<tr>
<th>Date</th>
<th>Intitul&eacute;</th>
<th>D&eacute;bit</th>
<th>Cr&eacute;dit</th>
</tr>
#for anItem in $historic_items
<tr>
<td>$anItem.date</td>
<td>$anItem.intitule</td>
#if $anItem.type=="debit"
<td>$anItem.montant</td>
#else
<td>&nbsp;<!-- evite que opera fasse des trucs bizarres... --></td>
#end if
#if $anItem.type=="credit"
<td>$anItem.montant</td>
#else
<td>&nbsp;<!-- evite que opera fasse des trucs bizarres... --></td>
#end if
</tr>
#end for
#if $historic_items == []
<tr><td colspan="4" style="color:gray;">
AUCUNE TRANSACTION ENREGISTR&Eacute;E
</td></tr>
#end if
</table>
</div>
<!-- ********************** Menu ********************** -->
</div>
</div>

View file

@ -0,0 +1,107 @@
<div id="messagePlaceHolder"></div>
#if $message != ''
<script type="text/javascript">setMessage('$message.replace("\'","\\\'")')</script>
#end if
#if $error != ''
<script type="text/javascript">setMessage('$error.replace("\'","\\\'")', 'errorMessage')</script>
#end if
<script type="text/javascript">
function showDetail(id){
slideDown(id, {duration:0.4});
var element = document.getElementById("togglelink" + id);
element.onclick=null;
element.style.backgroundPosition='bottom left';
setTimeout("var element = document.getElementById(\'togglelink" + id + "\');element.onclick=function () {hideDetail(\'" + id + "\'); return false;};",450);
return false;
}
function hideDetail(id){
slideUp(id, {duration:0.4});
var element = document.getElementById("togglelink" + id);
element.onclick=null;
element.style.backgroundPosition="top left";
setTimeout("var element = document.getElementById(\'togglelink" + id + "\');element.onclick=function () {showDetail(\'" + id + "\'); return false;};",450);
return false;
}
</script>
<div id="globalDiv">
<ul id="actionMenu">
<li><a href="index">Mes factures PayPal</a></li>
<li><a href="historique">Historique des transactions</a></li>
</ul>
<div id="factureListDiv">
<h1>Mes factures PayPal</h1>
<!-- <table id="listeFactures" cellspacing="0" border="0"> -->
#for f in $listeFactures
#if $f.payee
<div class="factureRow facturePayee">
#else
<div class="factureRow factureNonPayee">
#end if
<div class="factureSummary">
<span class="intitule">
#if $f.details.__len__() > 1
<a href="#" class="linkToggle" id="togglelinkfacture$f.no" onclick="showDetail('facture$f.no'); return false;"></a>
#end if
$f.intitule
#if not $f.payee
(non pay&eacute;e)
#end if
</span>
<span class="montant">
$f.montant&nbsp;&euro;
</span>
<span class="note" style="float:left;clear: left;">Cr&eacute;e le -</span>
#if not $f.payee
<span class="actions">
<a href="delFacture?no=$f.no">Annuler</a>
<a href="$f.paypal">Payer avec PayPal</a>
</span>
#else
<span class="note" style="float:right;clear:right;">Pay&eacute;e</span>
#end if
</div>
#if $f.details.__len__() > 1
<div id="facture$f.no" style="display:none;">
<table cellspacing="0" border="0" class="factureDetails">
<tr>
<th style="width:80%">Description</th>
<th>Prix unitaire</th>
<th>Quantit&eacute;</th>
<th>total</th>
</tr>
#for unDetail in $f.details
<tr>
<td>$unDetail.intitule</td>
<td>$unDetail.prixUnitaire&nbsp;&euro;</td>
<td>$unDetail.quantite</td>
<td>$unDetail.prixTotal&nbsp;&euro;</td>
</tr>
#end for
<tr>
<td colspan="3" class="tdTotalDetailIntitule">
Total
</td>
<td class="tdTotalDetail">$f.montant&nbsp;&euro;</td>
</tr>
</table>
</div>
</div>
#end if
#end for
#if $listeFactures == []
<div class="factureRow tdNoFactures">
AUCUNE TRANSACTION PAYPAL ENREGISTR&Eacute;E
</div>
#end if
</div>
</div>

View file

@ -0,0 +1,237 @@
#!/usr/bin/env python
# -*- coding: iso-8859-15 -*-
# #############################################################
# ..
# .... ............ ........
# . ....... . .... ..
# . ... .. .. .. .. ..... . ..
# .. .. ....@@@. .. . ........ .
# .. . .. ..@.@@..@@. .@@@@@@@ @@@@@@. ....
# .@@@@. .@@@@. .@@@@..@@.@@..@@@..@@@..@@@@.... ....
# @@@@... .@@@.. @@ @@ .@..@@..@@...@@@. .@@@@@. ..
# .@@@.. . @@@. @@.@@..@@.@@..@@@ @@ .@@@@@@.. .....
# ...@@@.... @@@ .@@.......... ........ ..... ..
# . ..@@@@.. . .@@@@. .. ....... . .............
# . .. .... .. .. . ... ....
# . . .... ............. .. ...
# .. .. ... ........ ... ...
# ................................
#
# #############################################################
#
# interface d'impression
#
# Copyright (c) 2006 by www.crans.org
# #############################################################
import cherrypy, tempfile, shutil, os
import crans.impression
import crans.impression.digicode
import crans.impression.etat_imprimante
import crans.cp
FILE_UPLOAD_BASE_FOLDER = cherrypy.config.get('fileUpload.folder', "/var/impression/fichiers/")
class FileError(Exception):
pass
from ClassesIntranet.ModuleBase import ModuleBase
class main(ModuleBase):
def category(self):
return "Services"
def title(self):
return "Impression"
def icon(self):
return "icon.png"
##########################
# affichage
##########################
#
# template principale
#
def index(self, submit = None, fileList = None, newFile = None ):
data = {}
# on efface un eventuel objet impression existant
cherrypy.session['impression'] = None
if submit == "Envoyer":
try:
self.savePDF(newFile)
data['fileName'] = newFile.filename
except FileError, e:
data['openError'] = e.args[0]
elif submit == "Choisir":
if (fileList):
data['fileName'] = fileList
else:
data['openError'] = "Choisissez un fichier"
data['fileList'] = self.getUploadedFileListFor(cherrypy.session['uid'])
try:
crans.impression.etat_imprimante.etat()
except Exception, e:
data['Erreur_imprimante'] = str(e).replace("\"", "\\\"")
data['errorMsg'] = u"Imprimante injoignable"
if not cherrypy.config.get('crans.activate', True):
data['Erreur_imprimante'] = "Config impression"
data['errorMsg'] = cherrypy.config.get('crans.activate.errorMsg', u"Imprimante HS")
return {'template':'impression',
'values':data,
'stylesheets':['impression.css'],
'scripts':['impression.js', 'popup.js'],
}
index.exposed = True
##########################
# 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
##########################
# AJAX
##########################
#
# methode qui renvoie la liste des codes de l'adherent
#
def codeList(self):
try:
listeBrute = crans.impression.digicode.list_code()
# liste de la forme :
# [(code, age, description),...]
listeBrute = [item[0] for item in listeBrute if item[2] == cherrypy.session['uid']]
return {'codes': listeBrute}
except Exception, e:
crans.cp.log('erreur lors de la creation de la liste de codes :' + str(e), 'IMPRESSION', 1)
return {'erreur':str(e)}
codeList.exposed= True
#
# methode qui indique quel fichier utiliser
#
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 crans.impression.FichierInvalide, e:
crans.cp.log("useFile : %s (%s)" % (str(e), e.file()), 'IMPRESSION', 1)
return {'erreur':str(e) }
except Exception, e:
crans.cp.log("useFile : %s" % str(e), 'IMPRESSION', 1)
return {'erreur':str(e) }
useFile.exposed= True
#
# methode pour changer les parametres
#
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:
crans.cp.log("changeSettings : %s" % str(e), 'IMPRESSION', 1)
return {"erreur":str(e)}
return {'nouvPrix':nouvPrix}
changeSettings.exposed = True
#
# methode pour lancer l'impression
#
def lancerImpression(self):
try:
cherrypy.session['impression'].imprime()
except crans.impression.SoldeInsuffisant:
return {"SoldeInsuffisant":1}
except Exception, e:
crans.cp.log("lancerImpression : %s" % str(e), 'IMPRESSION', 1)
return {"erreur":str(e)}
crans.cp.log("impression", 'IMPRESSION')
return {'code':str(crans.impression.digicode.gen_code(cherrypy.session['uid'])) + "#"}
lancerImpression.exposed = True
#
# methode pour recuperer l'etat de l'imprimante
#
def etatImprimante(self):
if not cherrypy.config.get('crans.activate', True):
return {"printer_state" : u"Système down"}
try:
return {"printer_state" : u"\\n".join(crans.impression.etat_imprimante.etat())}
except Exception, e:
return {"printer_state" : 'Imprimante hors ligne'}
etatImprimante.exposed = True
#
# methode pour le solde
#
def AJAXGetSolde(self):
try:
adh = cherrypy.session['LDAP'].search('uid=' + cherrypy.session['uid'])['adherent'][0]
return {"solde" : adh.solde() }
except Exception, e:
return {"erreur" : str(e)}
AJAXGetSolde.exposed = True
##########################
# privees
##########################
#
# methode pour obtenir la liste des fichiers uploadés
#
def getUploadedFileListFor(self, adh):
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)
#
# methode pour enregistrer un fichier
#
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)
crans.cp.log("New file uploaded at : %s" % newFilePath, "IMPRESSION")
return newFilePath

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

View file

@ -0,0 +1,162 @@
/* ****************************************** *
* <!-- disposition générale -->
* ****************************************** */
#globalDiv {
padding-left:200px;
position: relative;
}
ul#actionMenu {
list-style-type:none;
position:absolute;
width:150px;
top:0;
left:0;
margin:20px;
padding:0;
}
ul#actionMenu li {
clear:both;
}
/* ****************************************** *
* <!-- file name, menu de gauche -->
* ****************************************** */
#fileName {
display: block;
width:150px;
text-align:center;
padding:50px 5px 5px 5px;
background: url(../images/pdf-icon.png) center top no-repeat;
margin:0 0 10px 0;
overflow:auto;
}
#actionMenu li {
margin: .8em 0;
}
#actionEtatImprimante {
padding:0.4em;
border: thin black solid;
}
/* ******************************************* *
* <!-- formulaire reglages impression -->
* ******************************************* */
form#form_impression {
margin: 0px;
font-size: 100%;
min-width:600px;
}
form#form_impression #preview {
border:1px black solid;
width:150px;
height:150px;
padding:10px;
background-color:#C0C0C0;
}
form#form_impression #rightColumn {
margin:10px 10px 10px 240px;
}
form#form_impression #leftColumn {
float:left;
width:170px;
margin:10px;
padding:0;
}
div#prix_placeholder {
margin:6px 0;
width:170px;
min-height:16px;
padding:0;
color:gray;
}
div#prix_placeholder img {
margin-right:2px;
float:right;
}
form#form_impression fieldset fieldset {
margin:10px;
}
form#form_impression>fieldset {
position:relative;
padding:20px;
}
.clear {
clear:both;
}
form#form_impression .bouttons {
text-align:right;
}
form#form_impression label.labelInput {
display:block;
width:4em;
margin-right:4px;
float:left;
text-align:right;
}
/* ****************************************** *
* <!-- popup choix fichier -->
* ****************************************** */
#popupFichiers {
background:#AE0F3E;
z-index:500;
float:left;
position:fixed;
min-width:450px;
top:110px;
left:20%;
right:20%;
padding:0;
}
#popupFichiers #insideDiv {
background:white;
margin:2px 5px;
}
#popupFichiers #insideDiv form {
margin:2px 5px;
}
#popupFichiers h1 {
font-size:1em;
margin:0;
text-align:center;
color:white;
}
#popupFichiers h1:before {
content:url("../images/WindowTitleLogo.png");
margin-right:5px;
}
#popupFichiers h2 {
font-size:1.1em;
border-bottom:thin black solid;
}
#popupFichiers select,
#popupFichiers input.file {
width:100%;
}
.button {
float:right;
}
/* ****************************************** *
* <!-- popup impression en cours -->
* ****************************************** */
div#printingPopupContent {
background: white url("../images/printer.png") left center no-repeat;;
padding:10px 10px 10px 115px;
min-height:100px;
}
#printingPopupContent a,
#printingPopupContent span {
display:block;
font-weight: bold;
margin:5px 0;
}

View file

@ -0,0 +1,404 @@
/* ************************************************************
* Impression
************************************************************
* Impression.settings : panneau de configuration
* Impression.popup : popup
* Impression.AJAX : ajax
*/
Impression = {};
/*****************************
Impression.settings
*****************************/
Impression.settings = {};
//
//// images : images used for previewing
//
Impression.settings.images = [
"portrait_couleurs_agraphediagonale.png",
"portrait_couleurs_pasdagraphes.png",
"portrait_couleurs_uneagraphe.png",
"portrait_couleurs_Deuxagraphes.png",
"portrait_couleurs_troisAgraphes.png",
"portrait_couleurs_stitching.png",
"portrait_nb_agraphediagonale.png",
"portrait_nb_pasdagraphes.png",
"portrait_nb_uneagraphe.png",
"portrait_nb_Deuxagraphes.png",
"portrait_nb_troisAgraphes.png",
"portrait_nb_stitching.png",
"portrait_transparent_couleurs.png",
"portrait_transparent_nb.png",
];
Impression.settings.preloadImage = function(imageName) {
var image = new Image();
image.src = "/static/images/"+imageName;
}
Impression.settings.preloadAllImages = function() {
log("Preloading images...");
map(this.preloadImage,this.images);
}
//
//// init : parse every field and display preview
//
Impression.settings.init = function () {
log("Init settings...");
this.theform = document.form_impression;
this.disableForm(false);
}
//
//// reset : reset form and then re-init settings
//
Impression.settings.reset = function () {
log("Reset form");
this.theform.reset();
this.init();
Impression.settings.update();
}
Impression.settings.disableForm = function(bool)
{
log("Set Disable Form : " + bool);
var fields = this.theform.elements;
for( var i=0; i< fields.length; i++)
{
this.setDisableField( fields[i], bool );
}
}
//
//// getValue : parse a field and store value in fielld.name
//
Impression.settings.getValue = function(field)
{
if (field.value)
{
this[field.name] = field.value;
log( field.name + " is now " + this[field.name]);
}
else
{
logError("Can't get fieldValue");
}
}
//
//// getCopies : parse copies field
//
Impression.settings.getCopies = function(field) {
if ( (!field.value) || (parseInt(field.value)!=field.value-0) || (parseInt(field.value) < 1) )
{
this.copies = 1;
logError("Can't get copies");
}
else
{
this.copies = parseInt(field.value);
}
log("copies is now " + this.copies);
}
//
//// setValue : set field value
//
Impression.settings.setValue = function(afield, avalue) {
afield.value = avalue;
this.getValue(afield);
}
//
//// setDisableField : set field disabled on/off
//
Impression.settings.setDisableField = function( afield, isdisabled ) {
afield.disabled = isdisabled ;
}
//
//// disableField : set field disabled on
//
Impression.settings.disableField = function(afield) {
this.setDisableField(afield, true);
}
//
//// fieldChanges : when a field is changed
//
Impression.settings.update = function () {
var orientation = "portrait";
if (this.theform.type_impression_couleur.checked)
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
this.getValue(this.theform.disposition_recto_verso);
this.getValue(this.theform.papier);
this.getCopies(this.theform.nb_copies);
this.getValue(this.theform.agrafes);
// Contraintes
if (
( this.papier != "A4" ) ||
( (this.disposition == "recto") && (this.nb_pages>50) ) ||
( (this.disposition == "rectoverso") && (this.nb_pages>100) ) )
{
this.setValue(this.theform.agrafes, "pasdagraphes");
this.disableField(this.theform.agrafes);
this.getValue(this.theform.agrafes);
} else {
this.setDisableField(this.theform.agrafes, false);
}
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
{
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()
{
var image_name = "";
if (this.papier == "A4tr")
image_name = "portrait_transparent_" + this.type_impression + ".png";
else
image_name = "portrait_" + this.type_impression + '_' + this.agrafes + ".png";
var image = createDOM("IMG",{'src':'/static/images/'+image_name});
log("Updating preview (new image : " + image_name + ")");
replaceChildNodes("preview",image)
}
/*****************************
Impression.popup
*****************************/
Impression.popup = {};
Impression.popup.popupImpression = function(code) {
Popup.hide();
Popup.create({}, "Impression en cours...",
DIV(
{"id":"printingPopupContent", "style":"background-image:url(/static/images/dialog-printer.png)"},
SPAN("code: "+code),
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/images/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")));
Popup.display();
}
Impression.popup.popupSolde = function(code) {
Popup.hide();
Popup.create({}, "Solde insuffisant",
DIV(
{"id":"printingPopupContent", "style":"background-image:url(/static/images/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")));
Popup.display();
}
Impression.popup.popupCodes = function(codeList) {
Popup.hide();
Popup.create({}, "Codes de mes impressions",
DIV(
{"id":"printingPopupContent", "style":"background-image:url(/static/images/dialog-printer.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)),
Popup.closeLink({"class":"aide", "style":"text-align:right;"}, "Fermer")));
Popup.display();
}
/*****************************
Impression.mesCodes
*****************************/
Impression.mesCodes = {};
Impression.mesCodes.getCodes = function ()
{
Impression.AJAX.call('codeList', this.displayCodes );
}
Impression.mesCodes.displayCodes = function (result) {
if (result.codes)
Impression.popup.popupCodes(result.codes);
else if (result.erreur)
logError('erreur distante (codeLlist) : ' + result.erreur);
else
logError('erreur bizarre (codeLlist) : ');
}
/*****************************
Impression.AJAX
*****************************/
Impression.AJAX = {};
Impression.AJAX.modifPrix = function( text, wheel )
{
if (wheel)
{
var image = createDOM("IMG",{'src':'/static/images/indicator.gif'});
}
else
{
var image = new DIV({});
}
var item = new DIV({'onclick':'Impression.AJAX.recalcPrix();'}, image, text);
replaceChildNodes("prix_placeholder",item);
}
Impression.AJAX.modifNbPages = function( nbpages )
{
Impression.settings.nb_pages = nbpages;
replaceChildNodes("fileNbPages",nbpages);
}
Impression.AJAX.call = function(page, callBack) {
logDebug("calling AJAX : " + page);
var e = loadJSONDoc(page);
e.addCallback(callBack);
e.addErrback(this.errorHandler);
}
Impression.AJAX.errorHandler = function(d) {
logError("AJAX Error: " + d);
//Impression.AJAX.modifPrix("Erreur...", false);
}
Impression.AJAX.usefile = function(filename) {
var item = new DIV({}, "Calculs en cours...");
this.modifPrix("Analyse du fichier...", true);
this.call('useFile?fileName=' + filename,this.analysefini );
}
Impression.AJAX.analysefini = function(AJAXResp)
{
logDebug('AJAX terminated (usefile)');
if (AJAXResp.erreur) {
Impression.AJAX.modifPrix(AJAXResp.erreur, false);
Impression.popup.popupError(AJAXResp.erreur);
Impression.settings.disableForm(true);
logWarning('Erreur distante : ' + AJAXResp.erreur);
} else {
Impression.AJAX.modifPrix("Analyse terminée", true);
Impression.settings.update();
Impression.AJAX.modifNbPages(AJAXResp.nbPages);
}
}
Impression.AJAX.recalcPrix = function()
{
settings = Impression.settings;
var url = "changeSettings?copies=" + settings.copies
+"&couleurs="+ settings.type_impression
+"&papier="+ settings.papier
+"&recto_verso="+ settings.disposition
+"&agrafes="+ settings.agrafes;
this.modifPrix("Calcul en cours", true);
this.call(url, this.changePrix);
}
Impression.AJAX.changePrix = function(AJAXResp)
{
logDebug('AJAX terminated (recalcPrix)');
if (AJAXResp.erreur) {
Impression.AJAX.modifPrix(AJAXResp.erreur, false);
Impression.popup.popupError(AJAXResp.erreur);
Impression.settings.disableForm(true);
logWarning('Erreur distante : ' + AJAXResp.erreur);
} else {
Impression.AJAX.modifPrix("Coût : " + AJAXResp.nouvPrix + "€", false);
}
}
Impression.AJAX.lancerImpression = function(AJAXResp)
{
var url = "lancerImpression";
Impression.settings.disableForm(true);
this.call(url, this.finImpression);
}
Impression.AJAX.finImpression = function(AJAXResp)
{
logDebug('AJAX terminated (lancerImpression)');
if (AJAXResp.erreur) {
Impression.popup.popupError(AJAXResp.erreur);
logWarning('Erreur distante : ' + AJAXResp.erreur);
} else if (AJAXResp.SoldeInsuffisant) {
Impression.popup.popupSolde();
Impression.settings.disableForm(false);
Impression.settings.update();
} else {
Impression.popup.popupImpression(AJAXResp.code);
}
Impression.AJAX.updateSolde();
}
Impression.AJAX.getPrinterState = function()
{
var url = "etatImprimante";
Impression.AJAX.call(url, Impression.AJAX.displayPrinterState);
}
Impression.AJAX.displayPrinterState = function(AJAXResp)
{
logDebug('AJAX terminated (getPrinterState)');
if (AJAXResp.erreur) {
logWarning('Erreur distante (etatImprimante) : ' + AJAXResp.erreur);
} else {
replaceChildNodes("etatImprimanteIci", AJAXResp.printer_state)
}
}
Impression.AJAX.updateSolde = function()
{
var url = "AJAXGetSolde";
Impression.AJAX.call(url, Impression.AJAX.displaySolde);
}
Impression.AJAX.displaySolde = function(AJAXResp)
{
logDebug('AJAX terminated (updateSolde)');
if (AJAXResp.erreur) {
logWarning('Erreur distante (etatImprimante) : ' + AJAXResp.erreur);
} else {
replaceChildNodes("soldePlaceHolder", AJAXResp.solde )
}
}
setInterval(Impression.AJAX.getPrinterState, 30000);
setInterval(Impression.AJAX.updateSolde, 60000);

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5 KiB

View 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&eacute;</th>
<th>total</th>
</tr>
#for anItem in $devis
<tr>
<td>$anItem[0]</td>
<td>$anItem[1]&nbsp;&euro;</td>
<td>$anItem[2]</td>
<td>
#echo str($anItem[1] * $anItem[2]) + '&nbsp;&euro;'
</td>
</tr>
#end for
<tr>
<td colspan="3" class="tdTotalDetailIntitule">
Total
</td>
<td class="tdTotalDetail">$total&nbsp;&euro;</td>
</table>
</div>
</div>
</body>
</html>

View file

@ -0,0 +1,170 @@
#import crans.impression
#if $getVar('errorMsg',False)
<script type="text/javascript">
<!--
Crans.messages.setMessage('$errorMsg.replace("\'","\\\'")', 'errorMessage')
//-->
</script>
#end if
<div id="globalDiv">
<form id="form_impression" name="form_impression" onsubmit="Impression.popup();return false;" action="index">
<fieldset><legend>Options d'impression</legend>
<div id="leftColumn">
<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">
<input type="radio" name="type_impression" id="type_impression_couleur" class="inputRadio" value="$crans.impression.IMPRESSION_COULEUR" checked="checked" onclick="Impression.settings.update(this);" />
Couleurs
</label>
<label for="type_impression_nb" class="labelRadio compact"><input type="radio" name="type_impression" id="type_impression_nb" class="inputRadio" value="$crans.impression.IMPRESSION_NB" onclick="Impression.settings.update(this);" />
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
<option value="$type_papier">$crans.impression.LABELS[type_papier]</option>
#end for
</select>
<br />
<label for="agrafes" class="labelInput">Agrafes:</label>
<select name="agrafes" id="agrafes" class="selectOne" onchange="Impression.settings.update(this);">
#for type_agrafes in $crans.impression.AGRAPHES_VALEURS_POSSIBLES
<option value="$type_agrafes">$crans.impression.LABELS[type_agrafes]</option>
#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" />
</fieldset>
<fieldset><legend>Disposition</legend>
<label for="disposition_recto" class="labelRadio compact">
<input type="radio" name="disposition" id="disposition_recto" class="inputRadio" value="$crans.impression.IMPRESSION_RECTO" onclick="Impression.settings.update(this);" />
Recto
</label>
<label for="disposition_recto_verso" class="labelRadio compact">
<input type="radio" name="disposition" id="disposition_recto_verso" class="inputRadio" value="$crans.impression.IMPRESSION_RECTO_VERSO" checked="checked" onclick="Impression.settings.update(this);" />
Recto-verso
</label>
</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')" />
<input type="button" value="Imprimer" onclick="Impression.AJAX.lancerImpression();"/>
</div>
</fieldset>
</form>
<ul id="actionMenu">
#if $getVar('fileName',False)
<li id="fileName"><span>$fileName</span></li>
<li><span style="font-weight:bold;">pages: </span><span id="fileNbPages"></span></li>
<hr />
#end if
<li id="actionNouvelleImpression"><a href="index">Nouvelle impression</a></li>
<li id="actionMesCodes"><a href="#" onclick="Impression.mesCodes.getCodes(); return false;">Mes codes</a></li>
<li id="actionMesCodes" onclick="Impression.AJAX.updateSolde(); return false;">
<span style="font-weight:bold;">Solde: </span>
<span id="soldePlaceHolder">-</span> &euro;
</li>
<script type="text/javascript">
<!--
Impression.AJAX.updateSolde();
//-->
</script>
<li id="actionEtatImprimante" onclick="Impression.AJAX.getPrinterState();">
<span style="font-weight:bold;">&Eacute;tat imprimante:</span><br />
<span id="etatImprimanteIci"> - </span>
</li>
<script type="text/javascript">
<!--
Impression.AJAX.getPrinterState();
//-->
</script>
</ul>
#if not $getVar('Erreur_imprimante',False)
#if not $getVar('fileName',False)
<div id="popupFichiers">
<h1>Impression - Choix fichier</h1>
<div id="insideDiv">
#if $getVar('openError',False)
<div style="text-align:center;width:40%;border:2px solid red;margin:5px auto;padding:5px 10px;">$openError</div>
#end if
<p class="crans_warning">Il semblerait que l'interface d'impression ne soit
pas compatible avec internet explorer. Nous esp&eacute;rons pouvoir
r&eacute;gler ce probl&egrave;me au plus vite. Nous vous conseillons en attendant
d'utiliser <a href="http://www.mozilla-europe.org/fr/products/firefox/">Firefox</a>. <span class="crans_signature">Les
nounous</span> </p>
<form method="post" action="./" enctype="multipart/form-data">
<h2>Mes fichiers</h2>
<div>
<select name="fileList" id="fileList" size="5">
#for $file in $fileList
<option>$file</option>
#end for
</select>
</div>
<div class="buttons">
<input type="submit" name="submit" class="button" value="Choisir" />
</div>
<h2>Envoyer un fichier</h2>
<div>
<input type="file" name="newFile" class="file" />
<input type="submit" name="submit" value="Envoyer" class="button">
</div>
</form>
<div class="clear"></div>
</div>
</div>
<script type="text/javascript">
roundElement("popupFichiers");
roundElement("insideDiv");
</script>
#end if
</div>
#if $getVar('fileName',False)
<script type="text/javascript">
<!--
Impression.settings.init();
//Impression..AJAX.updateSolde();
Impression.AJAX.usefile('$fileName');
Impression.settings.preloadAllImages();
//-->
</script>
#else
<script type="text/javascript">
<!--
Impression.settings.init();
//Impression..AJAX.updateSolde();
Impression.settings.disableForm(true);
//-->
</script>
#end if
#else
## desactivation de l'interface si l'imprimant a un probleme
<script type="text/javascript">
<!--
Impression.settings.init();
//Impression.AJAX.updateSolde();
Impression.settings.disableForm(true);
logError("$Erreur_imprimante");
//-->
</script>
#end if

View file

@ -0,0 +1,16 @@
from ClassesIntranet.ModuleBase import ModuleBase
class main(ModuleBase):
def category(self):
return u"Services"
def title(self):
return u"Informations utiles"
def index(self):
return {
'template':'info-diverses',
'values':{},
'stylesheets':['infos.css'],
}
index.exposed = True

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

View file

@ -0,0 +1,75 @@
/*************************************************************
..
.... ............ ........
. ....... . .... ..
. ... .. .. .. .. ..... . ..
.. .. ....@@@. .. . ........ .
.. . .. ..@.@@..@@. .@@@@@@@ @@@@@@. ....
.@@@@. .@@@@. .@@@@..@@.@@..@@@..@@@..@@@@.... ....
@@@@... .@@@.. @@ @@ .@..@@..@@...@@@. .@@@@@. ..
.@@@.. . @@@. @@.@@..@@.@@..@@@ @@ .@@@@@@.. .....
...@@@.... @@@ .@@.......... ........ ..... ..
. ..@@@@.. . .@@@@. .. ....... . .............
. .. .... .. .. . ... ....
. . .... ............. .. ...
.. .. ... ........ ... ...
................................
==============================================================
mainInterface.css - Intranet Style
Mise en page de l'accueil
Copyright (c) 2006 by www.crans.org
**************************************************************/
div.framed_gray {
border:5px solid #e2e2e2; /* #acc0ff */
background-color:#f2f2f2;
padding:10px;
}
div.framed_gray fieldset {
border-width:2px;
border-style:solid none none none;
border-color:#a2a2a2;
padding:10px;
margin:10px 10px;
font-weight:bold;
}
div.framed_gray fieldset legend {
color:#a2a2a2;
}
div.framed_gray fieldset ul {
list-style-type:none;
margin:0;
padding:0;
}
div.framed_gray fieldset ul li {
float:left;
height:70px;
width:100px;
margin:5px;
display:block;
text-align:center;
}
div.framed_gray fieldset ul li span {
margin-bottom:0;
display:block;
}
div.framed_gray fieldset ul a {
color:black;
text-decoration:none;
}
div.framed_gray fieldset ul li img {
margin:2px auto;
width:32px;
height:32px;
}

View file

@ -0,0 +1,17 @@
<div class="framed_gray">
<h1>Mots de passe Cr@ns</h1>
<h2>Pour les news</h2>
<dl>
<dt>Utilisateur :</dt>
<dd>Vivelapa</dd>
<dt>Mot de passe : </dt>
<dd>ranoia!</dd>
</dl>
<h2>Pour le wiki</h2>
<dl>
<dt>Utilisateur : </dt>
<dd>ViveLe</dd>
<dt>Mot de passe : </dt>
<dd>Wiki!</dd>
</dl>
</div>

View file

@ -0,0 +1,249 @@
#! /usr/bin/env python
# -*- coding: iso-8859-15 -*-
# ##################################################################################################### #
# Machines
# ##################################################################################################### #
# Description:
# Affiche la liste des machies, les infons sur une machine et permet des modifications
# Informations:
#
# Pages:
# index:liste des machines + le reste (AJAX)
#
# ##################################################################################################### #
import cherrypy, sys, os, datetime
from time import strftime, localtime, time
# libraries crans
sys.path.append('/usr/scripts/gestion/')
import crans.cp
if (cherrypy.config.configMap["global"]["server.environment"] == "development"):
from ldap_crans_test import *
# print("mesmachines : unsing test ldap : env=" + cherrypy.config.configMap["global"]["server.environment"])
else:
from ldap_crans import *
# print("mesmachines : unsing prod ldap : env=" + cherrypy.config.configMap["global"]["server.environment"])
from ClassesIntranet.ModuleBase import ModuleBase
class main(ModuleBase):
def title(self):
return "Mes Machines"
def icon(self):
return "machines_icon_fixe.png"
def AJAXListeMachines(self):
adh = cherrypy.session['LDAP'].search('uid=' + cherrypy.session['uid'])['adherent'][0]
machines = []
for une_machine in adh.machines():
machineInfos = {}
# nom, mac, mid, ip
machineInfos['nom'] = une_machine.nom()
machineInfos['nomCourt'] = une_machine.nom().split('.',1)[0]
machineInfos['mid'] = une_machine.id()
# type
if une_machine.objectClass == 'machineFixe':
machineInfos['type'] = 'fixe'
#machineInfos['type'] = 'Machine fixe'
else:
machineInfos['type'] = 'wifi'
#machineInfos['type'] = 'Machine wifi'
# clef ipsec
machines.append(machineInfos)
return {"machines":machines}
AJAXListeMachines.exposed = True
def AJAXMachineInfo(self, mid):
try:
machine = cherrypy.session['LDAP'].search('mid=' + mid)['machine'][0]
if machine.proprietaire().mail() != cherrypy.session['uid']:
raise Exception
# zamok -> pour tester l'affichage des ports, des alias
#machine = cherrypy.session['LDAP'].search('mid=896')['machine'][0]
machineInfos = {}
# nom, mac, mid, ip
machineInfos['nom'] = machine.nom()
machineInfos['nomCourt'] = machine.nom().split('.',1)[0]
machineInfos['mac'] = machine.mac()
machineInfos['mid'] = machine.id()
machineInfos['ip'] = machine.ip()
# type
if machine.objectClass == 'machineFixe':
machineInfos['type'] = 'fixe'
else:
machineInfos['type'] = 'wifi'
# clef ipsec
try:
machineInfos['ipsec'] = machine.ipsec()
except:
machineInfos['ipsec'] = ''
# alias
machineInfos['alias'] = machine.alias()
# blacklists
machineInfos['blacklist'] = []
for blacklist_type in machine.blacklist_all()[0].keys():
for (begin, end) in machine.blacklist_all()[0][blacklist_type]:
blacklist = {}
blacklist['begin'] = strftime('%d/%m/%Y %H:%M', localtime(int(begin)))
blacklist['end'] = strftime('%d/%m/%Y %H:%M', localtime(int(end)))
blacklist['type'] = blacklist_type
blacklist['actif'] = 1
machineInfos['blacklist'].append(blacklist)
for blacklist_type in machine.blacklist_all()[1].keys():
for (begin, end) in machine.blacklist_all()[1][blacklist_type]:
blacklist = {}
blacklist['begin'] = strftime('%d/%m/%Y %H:%M', localtime(int(begin)))
blacklist['end'] = strftime('%d/%m/%Y %H:%M', localtime(int(end)))
blacklist['type'] = blacklist_type
blacklist['actif'] = 0
machineInfos['blacklist'].append(blacklist)
# ports
machineInfos['ports'] = []
if machine.portTCPin() != []:
machineInfos['ports'].append(
{
'titre':'Ports TCP ouvert ext->machine',
'ports':machine.portTCPin()
}
)
if machine.portTCPout() != []:
machineInfos['ports'].append(
{
'titre':'Ports TCP ouvert machine->ext',
'ports':machine.portTCPout()
}
)
if machine.portUDPin() != []:
machineInfos['ports'].append(
{
'titre':'Ports UDP ouvert ext->machine',
'ports':machine.portUDPin()
}
)
if machine.portUDPout() != []:
machineInfos['ports'].append(
{
'titre':'Ports TCP ouvert machine->ext',
'ports':machine.portUDPout()
}
)
return machineInfos
except Exception, e:
return {"erreur":str(e)}
AJAXMachineInfo.exposed = True
##########################
# affichage
##########################
#
# methode qui affiche la template
#
def index(self):
return {
'template' :'machines',
'values' :{},
'stylesheets' :['machines.css'],
'scripts':['machines.js'],
}
index.exposed = True
###########################################################################
# methodes pour changer
# des valeurs
###########################################################################
#
##########################
# machine:nom
##########################
def AJAXChangerNom(self, mid, nouveauNom):
try:
adh = cherrypy.session['LDAP'].search('uid=' + cherrypy.session['uid'])['adherent'][0]
mach = cherrypy.session['LDAP'].search('mid=' + mid, 'w')['machine'][0]
# tester si c'est bien la machine de l'adherent
if mach.proprietaire().compte() != cherrypy.session['uid']:
del adh, mach
raise Exception(u"L'uid de l'adherent ne correspond mas au proprietaire de la machine.")
anciennom = mach.nom()
nouveauNom = mach.nom(nouveauNom)
mach.save()
del mach
except ValueError, e:
raise e
#return {'error':str(e)}
crans.cp.log("Changer nom machine : %s->%s" % (anciennom, nouveauNom), "MESMACHINES")
return {'message':u"Modification réussie", 'mid':mid}
AJAXChangerNom.exposed = True
##########################
# machine:mac
##########################
def AJAXchangerMAC(self, mid, nouvelleMAC):
try:
adh = cherrypy.session['LDAP'].search('uid=' + cherrypy.session['uid'])['adherent'][0]
mach = cherrypy.session['LDAP'].search('mid=' + mid, 'w')['machine'][0]
# tester si c'est bien la machine de l'adherent
if mach.proprietaire().compte() != cherrypy.session['uid']:
del adh, mach
raise Exception(u"L'uid de l'adherent ne correspond mas au proprietaire de la machine.")
anciennemac = mach.mac()
nommachine = mach.nom()
mach.mac(nouvelleMAC)
mach.save()
del mach
except ValueError, e:
return {'error':e.args[0]}
crans.cp.log("Change mac machine %s : %s->%s" % (nommachine, anciennemac, nouvelleMAC), "MESMACHINES")
return {'message':u"Modification réussie", 'mid':mid}
AJAXchangerMAC.exposed = True
##########################
# machine:suppression
##########################
def AJAXSupprimerMachine(self, mid):
try:
adh = cherrypy.session['LDAP'].search('uid=' + cherrypy.session['uid'])['adherent'][0]
mach = cherrypy.session['LDAP'].search('mid=' + mid, 'w')['machine'][0]
# tester si c'est bien la machine de l'adherent
if mach.proprietaire().compte() != cherrypy.session['uid']:
del adh, mach
raise Exception(u"L'uid de l'adherent ne correspond mas au proprietaire de la machine.")
mach.delete()
except ValueError, e:
return {'error':e.args[0]}
crans.cp.log("Machine supprimee", "MACHINES")
return {'message':u"Machine supprimée"}
AJAXSupprimerMachine.exposed = True
##########################
# machine:creation
##########################
def AJAXCreerMachine(self, nomNouvelleMachine, MACNouvelleMachine, typeNouvelleMachine):
adh = cherrypy.session['LDAP'].search('uid=' + cherrypy.session['uid'])['adherent'][0]
if typeNouvelleMachine=='fixe' and adh.droits() == [] and adh.machines_fixes() != []:
return {'error':'Vous avez deja une machine fixe. Vous ne pouvez ajouter que des machines WiFi.'}
try:
if typeNouvelleMachine=='wifi':
m = MachineWifi(adh)
elif typeNouvelleMachine=='fixe':
m = MachineFixe(adh)
else:
raise Exception, "type de machine inconnu : %s " % typeNouvelleMachine
m.nom(nomNouvelleMachine)
m.mac(MACNouvelleMachine)
m.ip("<automatique>")
message = m.save()
del m
except ValueError, e:
del m
return {'error':e.args[0].replace("\n","\\n")}
crans.cp.log("Nouvelle machine %s" % nomNouvelleMachine, "MACHINES")
return {'message':u"Machine enregistrée avec succès"}
AJAXCreerMachine.exposed = True

View file

@ -0,0 +1,160 @@
/*************************************************************
..
.... ............ ........
. ....... . .... ..
. ... .. .. .. .. ..... . ..
.. .. ....@@@. .. . ........ .
.. . .. ..@.@@..@@. .@@@@@@@ @@@@@@. ....
.@@@@. .@@@@. .@@@@..@@.@@..@@@..@@@..@@@@.... ....
@@@@... .@@@.. @@ @@ .@..@@..@@...@@@. .@@@@@. ..
.@@@.. . @@@. @@.@@..@@.@@..@@@ @@ .@@@@@@.. .....
...@@@.... @@@ .@@.......... ........ ..... ..
. ..@@@@.. . .@@@@. .. ....... . .............
. .. .... .. .. . ... ....
. . .... ............. .. ...
.. .. ... ........ ... ...
................................
==============================================================
macines.css - Intranet Style
Copyright (c) 2006 by www.crans.org
**************************************************************/
#globalDiv {
padding-left : 20%;
margin:0;
position:relative;
}
h2 {
margin: 0 5px .5em 5px;padding:5px;
}
div.alias {
color:gray;
margin:0;
padding:0 0 0 60px;
display:block;
font-weight:normal;
font-size:0.6em;
}
table.blacklist_table,
table.ports_table {
border-top: thin black solid;
border-left: thin black solid;
}
table.blacklist_table td,
table.blacklist_table th,
table.ports_table td,
table.ports_table th {
border-right: thin black solid;
border-bottom: thin black solid;
padding: 3px;
}
.actif {
color:red;
}
.inactif {
}
#gestion_machines_main_frame {
padding:5px;
}
dl.basicInfos dt {
float:left;
font-weight:bold;
clear:left;
}
dl.basicInfos dd {
float:left;
margin:0 1em;
}
ul#listeMachines {
list-style-type:none;
margin:0;
padding:0;
}
ul#listeMachines li {
float:left;
height:70px;
width:100px;
margin:5px;
display:block;
text-align:center;
}
ul#listeMachines li span {
margin-bottom:0;
display:block;
}
ul#listeMachines li a {
display:block;
color:black;
text-decoration:none;
}
ul#listeMachines li a:hover {
background:#bbbbff;
}
ul#listeMachines li a:active {
background:#8888ff;
}
ul#listeMachines li img {
margin:2px auto;
width:32px;
height:32px;
}
#menu_actions {
background:#eeeeff;
padding:.3em;
width:18%;
float:left;
position:absolute;
top:1em;
left:0;
border: thin black solid;
}
#menu_actions ul {
list-style-type:none;
padding:0;
margin:.5em;
}
#menu_actions ul li a {
text-decoration:none;
}
#menu_actions ul li a:hover {
text-decoration:underline;
}
#menu_actions h1 {
font-size:1em;
margin:0;
text-align:center;
border-bottom: thin black solid;
}
// on change la couleur des messages
.message {
background-color:#000080;
color:white;
}
label {
width:175px;
display:block;
float:left;
}

View file

@ -0,0 +1,348 @@
/* ************************************************************
* Machines
************************************************************
* Machines.init : initialisation de la page
* Machines.listeMachines : liste des machines
* Machines.infoPane : information sur une machine
* Machines.actions : modifications, ajout...
* Machines.AJAX : ajax
*/
Machines = {};
/*****************************
Machines.init
*****************************/
Machines.init = function()
{
// afficher le tableau codelist
appendChildNodes("globalDiv", Machines.createFrames());
appendChildNodes("globalDiv", Machines.actions.makeMenu());
// recuperer la liste des codes
this.listeMachines.load();
}
Machines.createFrames = function()
{
var main = DIV({"id":"gestion_machines_main_frame"});
var inside = DIV({"id":"__insideDivId", "style":"background:white;margin:5px;padding:5px;"},main);
var outside = DIV({"id":"__outsideDivId","style":"background:#000080;z-index:500;padding:0;"}, inside );
roundElement(outside);
roundElement(inside);
log("Creation du cadre");
return outside
}
/*****************************
Machines.listeMachines
*****************************/
Machines.listeMachines = {};
Machines.listeMachines.load = function()
{
Machines.AJAX.call("AJAXListeMachines", Machines.listeMachines.display);
log("Chargement liste...");
Machines.currentMachine = '';
}
Machines.listeMachines.display = function(result)
{
Crans.loading.display(false);
log("display liste");
replaceChildNodes( "gestion_machines_main_frame",
H2({}, "Mes machines"),
UL({"id":"listeMachines"}),
DIV( {"style":"clear:both;"} )
);
if (result.machines) {
replaceChildNodes('listeMachines',map(Machines.listeMachines.newMachineNodeFromDict ,result.machines));
Machines.actions.updateMenu(Machines.actions.actionForMachineList);
Machines.currentMid = '';
}
else if (result.erreur)
logError("Erreur distante : " + result.erreur);
else
logError("Probleme bizarre...");
}
Machines.listeMachines.newMachineNodeFromDict = function (aDict, style)
{
var nom = aDict.nomCourt;
var mid = aDict.mid;
var image = "machines_icon_" + aDict.type + ".png";
//log("create an item : " + nom);
if (style) {
var anIcon = LI({'id':'machine_' + mid,"style":style});
} else
var anIcon = LI( {'id':'machine_' + mid} );
appendChildNodes(anIcon, A({"href":"#", "onclick":"Machines.infoPane.loadInfo('"+mid+"');return false;"}, IMG({"src":"/static/images/" + image}), SPAN({},nom) ) );
return anIcon;
}
/*****************************
Machines.infoPane
*****************************/
Machines.infoPane = {};
Machines.infoPane.loadInfo = function(mid)
{
if (!mid)
if (!Machines.currentMachine) {
logError("Machines.infoPane.loadInfo : pas de mid, pas de machine courrante...");
return
} else
mid = Machines.currentMachine.mid;
log("load info : " + mid);
Machines.AJAX.call("AJAXMachineInfo?mid=" + mid, Machines.infoPane.display);
try {
pulsate('machine_' + mid);
} catch (error) {}
}
Machines.infoPane.display = function(result)
{
Crans.loading.display(false);
if (result.nom) {
log("displaying info : " + result.mid);
// building pane
var machinePane = DIV({"id":"machine_pane"});
// lien pour retourner a la liste des machines
var back_link = A({"href":"#", "onclick":"Machines.listeMachines.load(); return false;"},"Retour");
appendChildNodes( machinePane, back_link );
// titre (nom de machine + alias)
var title = H2({}, IMG({"src":"/static/images/machines_icon_" + result.type + ".png"}), " ", result.nom);
var alias = DIV({"class":"alias"},
map(function(a_name) { return SPAN({}, a_name + " ")}, result.alias));
appendChildNodes( title, alias );
appendChildNodes( machinePane, title );
// infos de base (type, mac, ip, ipsec...)
var basicInfos = createDOM("DL", {"class":"basicInfos"});
appendChildNodes(basicInfos, createDOM("DT", "type:" ), createDOM("DD",{},"Machine " + result.type ) );
appendChildNodes(basicInfos, createDOM("DT", "mac: " ), createDOM("DD",{},result.mac ) );
appendChildNodes(basicInfos, createDOM("DT", "ip: " ), createDOM("DD",{},result.ip ) );
if (result.ipsec)
appendChildNodes(basicInfos, createDOM("DT", "Clef ipSec:" ), createDOM("DD",{},result.ipsec ) );
appendChildNodes( machinePane, basicInfos );
appendChildNodes( machinePane, DIV( {"style":"clear:both;"} ) );
// blacklist
if (result.blacklist)
if (result.blacklist.length) {
var subtitle = H3({}, "Blacklist");
appendChildNodes( machinePane, subtitle );
var blacklist_table = TABLE({"class":"blacklist_table", "cellspacing":"0"},
THEAD({},
TH({}, "Cause"),
TH({}, "Debut"),
TH({}, "Fin")
)
);
map(function(a_blacklist_dict) {
var style = "inactif";
if (a_blacklist_dict.actif)
style = "actif";
var line = TR({"class":style},
TD({}, a_blacklist_dict.type),
TD({}, a_blacklist_dict.begin),
TD({}, a_blacklist_dict.end)
);
appendChildNodes(blacklist_table, line);
}, result.blacklist );
appendChildNodes( machinePane, blacklist_table );
}
// liste des ports ouverts
if (result.ports)
if (result.ports.length) {
var subtitle = H3({}, "Ports ouverts");
appendChildNodes( machinePane, subtitle );
var port_table = TABLE({"class":"ports_table", "cellspacing":"0"});
map(function(a_port_dict) {
var line = TR({},
TH({}, a_port_dict.titre),
map(function(a_port) {return TD({}, a_port);}, a_port_dict.ports)
);
appendChildNodes(port_table, line);
}, result.ports );
appendChildNodes( machinePane, port_table );
}
// attaching pane to document
replaceChildNodes( "gestion_machines_main_frame", machinePane);
// updationg actions
Machines.currentMachine = result;
Machines.actions.updateMenu(Machines.actions.actionsForInfoPane);
} else if (result.erreur) {
logError("Erreur distante : " + result.erreur);
} else
logError("Probleme bizarr...");
}
/*****************************
Machines.actions
*****************************/
Machines.actions = {}
Machines.actions.disponibles =
{
'Ajouter machine fixe':'Machines.actions.formulaire.nouvelleMachine(\'fixe\');',
'Ajouter machine wifi':'Machines.actions.formulaire.nouvelleMachine(\'wifi\');',
'Modifier Mac':'Machines.actions.formulaire.modifierMac(Machines.currentMid);',
'Renommer':'Machines.actions.formulaire.renommer(Machines.currentMid);',
'Supprimer':'Machines.actions.formulaire.supprimer(Machines.currentMid);',
'Demander l\'ouverture d\'un port':'Machines.actions.formulaire.ouverturePort(Machines.currentMid);'
}
Machines.actions.actionForMachineList = ['Ajouter machine fixe', 'Ajouter machine wifi'];
Machines.actions.actionsForInfoPane = ['Modifier Mac', 'Renommer', 'Supprimer'];
Machines.actions.makeMenu = function(actionListe)
{
log("building action menu");
var liste = UL({"id":"liste_actions"});
//this.updateMenu(actionListe, liste)
return DIV( {"id":"menu_actions"},
H1( {}, "ACTIONS"),
liste
);
}
Machines.actions.updateMenu = function(actionListe, liste_actionsNode)
{
if (!liste_actionsNode)
liste_actionsNode = "liste_actions";
replaceChildNodes(liste_actionsNode);
map(
function(actionName) {
appendChildNodes(liste_actionsNode, LI({}, Machines.actions.makeActionLink(actionName)));
}
, actionListe);
}
Machines.actions.makeActionLink = function(actionName)
{
if (this.disponibles[actionName])
{
return A({"href":"#", "onclick":this.disponibles[actionName] + "return false;"}, actionName);
} else
logError("action inconnue " + actionName);
return A({}, "???");
}
Machines.actions.callback = function(result) {
Crans.loading.display(false);
if (result.message){
log(result.message);
Crans.messages.setMessage(result.message);
if (result.mid)
Machines.infoPane.loadInfo(result.mid);
else
Machines.listeMachines.load();
}
if (result.error){
alert(result.error);
logError("AJAX error");
}
}
// actions : affichage des formulaires
Machines.actions.formulaire = {}
Machines.actions.formulaire.modifierMac = function()
{
if (!Machines.currentMachine)
logError("pas de machine courrante");
else {
var c = '';
while ( c == '')
c = prompt("Adresse MAC de la machine :",Machines.currentMachine.mac);
if (c == null)
return false;
// AJAX stuff
Machines.AJAX.call('AJAXchangerMAC?nouvelleMAC=' + c + '&mid=' + Machines.currentMachine.mid,
Machines.actions.callback);
}
return false;
}
Machines.actions.formulaire.renommer = function() {
if (!Machines.currentMachine)
logError("pas de machine courrante");
else {
var c = '';
while ( c == '')
c = prompt("Nom de la machine :",Machines.currentMachine.nomCourt);
if (c == null)
return false;
// AJAX stuff
Machines.AJAX.call('AJAXChangerNom?nouveauNom=' + c + '&mid=' + Machines.currentMachine.mid,
Machines.actions.callback);
}
return false;
}
Machines.actions.formulaire.supprimer = function() {
if (!Machines.currentMachine)
logError("pas de machine courrante");
else {
if (confirm("Supprimer la machine " + Machines.currentMachine.nomCourt +" ?")) {
// AJAX stuff
Machines.AJAX.call('AJAXSupprimerMachine?mid=' + Machines.currentMachine.mid,
Machines.actions.callback);
}
}
return false;
}
Machines.actions.formulaire.nouvelleMachine = function(type) {
replaceChildNodes( "gestion_machines_main_frame",
A({"href":"#", "onclick":"Machines.listeMachines.load(); return false;"},"Retour"),
H2({}, "Nouvelle machine"),
FORM({"style":"clear:both;", 'onsubmit':'Machines.actions.creerMachine(this.typeField.value, this.nom.value, this.mac.value);return false;'},
createDOM('label', {'for':'add_machine_nom'}, "Nom de la machine : "),
INPUT({"name":"nom"}),
BR(),
createDOM('label', {'for':'add_machine_mac'}, "Adresse MAC : "),
INPUT({"name":"mac"}),
BR(),
createDOM('label', {'for':'add_machine_type'}, "Type de machine : "),
SPAN({'id':'add_machine_type'}, type),
INPUT({"name":"typeField", 'type':'hidden', 'value':type}),
BR(),
BUTTON({"class":"liens", 'type':'submit'}, 'Ajouter')
)
);
return false;
}
Machines.actions.creerMachine = function(type, nom, mac) {
Machines.AJAX.call('AJAXCreerMachine?nomNouvelleMachine=' + nom
+ '&MACNouvelleMachine=' + mac
+ '&typeNouvelleMachine=' + type,
Machines.actions.callback);
}
/*****************************
Machines.AJAX
*****************************/
Machines.AJAX = {}
Machines.AJAX.call = function(page, callBack) {
logDebug("calling AJAX : " + page);
var e = loadJSONDoc(page);
e.addCallback(callBack);
e.addErrback(this.errorHandler);
Crans.loading.display(true);
}
Machines.AJAX.errorHandler = function(d) {
//Machines.AJAX..modifPrix("Erreur", false);
logError("AJAX Error: " + d);
Crans.loading.display(false);
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

View file

@ -0,0 +1,359 @@
#! /usr/bin/env python
# -*- coding: iso-8859-15 -*-
# ##################################################################################################### #
# MonCompte
# ##################################################################################################### #
# Description:
#
# Informations:
#
# Pages:
#
#
# ##################################################################################################### #
import cherrypy, sys, os, datetime
# libraries crans
import crans.cp as _crans_cp
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"])
else:
from ldap_crans import *
# print("monCompte : unsing prod ldap : env=" + cherrypy.config.configMap["global"]["server.environment"])
from ClassesIntranet.ModuleBase import ModuleBase
class main(ModuleBase):
def title(self):
return "Mon Compte"
def getCurrentAdministrativeYear(self):
'''
premiere partie de l''annee scolaire en cours
ex : le 5 juin 2006 retourne 2005
'''
now = datetime.datetime.now()
currentYear = int(now.strftime("%Y"))
currentMonth = int(now.strftime("%m"))
if currentMonth > 8:
administrativeYear = currentYear
else:
administrativeYear = currentYear - 1
return administrativeYear
##########################
# affichage
##########################
#
# methode qui affiche la template avec toutes les infos de
# l'adherent + les formulaires
#
def index(self, message = '', error = '', currentTab = 'mainTab'):
adh = cherrypy.session['LDAP'].search('uid=' + cherrypy.session['uid'])['adherent'][0]
t = {}
t['message'] = message
t['error'] = error
############## info adherent ##############
adherent = {}
# nom, prenom, chambre, tel, solde, droits, mail
adherent['prenom'] = adh.prenom()
adherent['nom'] = adh.nom()
adherent['chambre'] = adh.chbre()
if adherent['chambre'] == "EXT":
adr = adh.adresse()
adherent['adresse'] = {}
adherent['adresse']['ligne1'] = adr[0]
adherent['adresse']['ligne2'] = adr[1]
adherent['adresse']['cp'] = adr[2]
adherent['adresse']['ville'] = adr[3]
adherent['telephone'] = adh.tel
adherent['solde'] = adh.solde
adherent['droits'] = u", ".join(adh.droits())
adherent['mail'] = adh.email()
# cotisation
administrativeYear = self.getCurrentAdministrativeYear()
if administrativeYear in adh.paiement():
adherent['cotisationOK'] = 'OK'
else:
adherent['cotisationOK'] = None
# carte etudiant
if administrativeYear in adh.carteEtudiant():
adherent['carteOK'] = 'OK'
else:
adherent['carteOK'] = None
# annee scolaire (ex 2001-2002)
adherent['anneeScolaire'] = str(administrativeYear) + '-' + str(administrativeYear + 1)
t['adherent'] = adherent
############## info mail ##############
mailInfos = {}
try:
mailConfig = MailConfig(cherrypy.session['uid'])
mailInfos['forwarding_address'] = mailConfig['forward']
mailInfos['spam'] = {}
mailInfos['spam']['no'] = mailConfig['spam'] == 'accepte'
mailInfos['spam']['mark'] = mailConfig['spam'] == 'marque'
mailInfos['spam']['drop'] = mailConfig['spam'] == 'supprime'
except Exception, e:
t['mailError'] = u"Erreur:fichiers de configuration mail personnels"
mailInfos['alias'] = adh.alias()
mailInfos['contourneGreylist'] = adh.contourneGreylist()
mailInfos['rewriteMailHeaders'] = adh.rewriteMailHeaders()
t['mailInfos'] = mailInfos
return {
'template' :'monCompte',
'values' :t,
'stylesheets' :['monCompte.css'],
'scripts':['crans_domtab.js','moncompte.js','passwordGenerator.js'],
}
index.exposed = True
##########################
# paypal
##########################
#
# methode qui affiche successivement les
# templates du popup pour recharger son compte impression
# via paypal
#
def rechargerCompteImpression(self, etape = '1', combien = None):
adh = cherrypy.session['LDAP'].search('uid=' + cherrypy.session['uid'])['adherent'][0]
if (etape == "1"): # Introduction
return {
'template' :'MonCompteRechargePaypal1',
'standalone' :True,
'values' :{},
}
elif (etape == "2"): # choix montant
return {
'template' :'MonCompteRechargePaypal2',
'standalone' :True,
'values' :{},
}
elif (etape == "3"): # confirmer facture
# creer objet facture
f = Facture(adh)
# /!\ verifier que combien est un nombre
# et qu'il n'y a pas plus de 2 chiffres après le point...
# (ce serait bien aussi si on pouvait mettre une virgue a la place du point)
try:
# remplacage des virgules
combien = combien.replace(u',', u'.')
# convertissage
combien = float(combien)
# arrondissage-tronquage :
combien = float(int(combien*100)/100.0)
# nombre positif
if combien < 0:
raise ValueError
except Exception:
return {
'template' :'MonCompteRechargePaypal2',
'standalone' :True,
'values' :{'error':"Le montant doit &ecirc;tre un nombre positif !", 'combien':combien},
}
f.ajoute({'nombre': 1, 'code': 'SOLDE', 'designation': 'Credit du compte impression (intranet)', 'pu': combien})
cherrypy.session['freshFacture'] = f
pageData = {}
pageData['details'] = [
{
'intitule':art['designation'],
'quantite':art['nombre'],
'prixUnitaire':art['pu'],
'prixTotal':art['pu']*art['nombre'],
} for art in f.articles()]
pageData['total'] = f.total()
return {
'template' :'MonCompteRechargePaypal3',
'standalone' :True,
'values' :pageData,
}
elif (etape == "4"):# payer maintenant ?
# sauver objet facture
f = cherrypy.session['freshFacture']
f.save()
return {
'template' :'MonCompteRechargePaypal4',
'standalone' :True,
'values' :{'lienPaypal' : f.urlPaypal(useSandbox = cherrypy.config.get("paypal.useSandbox", False),
businessMail = cherrypy.config.get("paypal.businessAdress", "paypal@crans.org"),
return_page = "https://intranet.crans.org/monCompte/paypalReturn",
cancel_return_page = "https://intranet.crans.org/monCompte/paypalCancel",
)},
}
rechargerCompteImpression.exposed = True
def paypalReturn(self, **kw):
_crans_cp.log("retour de paypal avec les infos : %s" % " ".join( [ "[%s: %s]" % (str(a), str(kw[a])) for a in kw] ) )
return {
'template' :'MonComptePaypalReturn',
'standalone' :True,
'values' :{},
}
paypalReturn.exposed = True
def paypalCancel(self, **kw):
_crans_cp.log("annulation de paypal avec les infos : %s" % " ".join( [ "[%s: %s]" % (str(a), str(kw[a])) for a in kw] ) )
return {
'template' :'MonComptePaypalCancel',
'standalone' :True,
'values' :{},
}
paypalCancel.exposed = True
###########################################################################
# methodes pour changer
# des valeurs
###########################################################################
#
# En fait, les methodes recoivent les valeurs d'un formulaire
# (ou equivalent de javascript), font la modification puis
# appellent la methode principale d'affichage
# en lui passant eventuellement un message a afficher
# (pour indiquer la reussite ou non de l'operation)
#
##########################
# Adherent:nom
##########################
def changeNomAdherent(self, nouveauNom):
adh = cherrypy.session['LDAP'].search('uid=' + cherrypy.session['uid'], 'w')['adherent'][0]
try:
ancienNom = adh.nom()
adh.nom(nouveauNom)
adh.save()
except ValueError, e:
return self.index(error=e.args[0])
del adh
_crans_cp.log("Change nom : %s -> %s" % (ancienNom, nouveauNom), "MONCOMPTE")
return self.index(message=u'Modification réussie')
changeNomAdherent.exposed = True
##########################
# Adherent:password
##########################
def changePasswordAdherent(self, ancienPassword, nouveauPassword1, nouveauPassword2):
if ancienPassword=='':
msg = 'Erreur, mot de passe incorrect'
return self.index(error=msg)
if nouveauPassword1=='':
msg = 'Erreur, le nouveau mot de passe ne doit pas &egrave;tre vide.'
return self.index(error=msg)
if nouveauPassword1!=nouveauPassword2:
msg = 'Erreur, la confirmation ne correspond pas au nouveau mot de passe.'
return self.index(error=msg)
adh = cherrypy.session['LDAP'].search('uid=' + cherrypy.session['uid'],'w')['adherent'][0]
if adh.checkPassword(ancienPassword):
adh.changePasswd(nouveauPassword1)
adh.save()
msg = u'Changement effectué'
else:
msg = 'Erreur, mot de passe incorrect'
return self.index(error=msg)
del adh
_crans_cp.log("Change password", "MONCOMPTE")
return self.index(message=msg)
changePasswordAdherent.exposed = True
##########################
# Adherent:prenom
##########################
def changePrenomAdherent(self, nouveauPrenom):
adh = cherrypy.session['LDAP'].search('uid=' + cherrypy.session['uid'], 'w')['adherent'][0]
try:
ancienPrenom = adh.prenom()
adh.prenom(nouveauPrenom)
adh.save()
except ValueError, e:
return self.index(error=e.args[0])
del adh
_crans_cp.log("Change prenom : %s -> %s" % (ancienPrenom, nouveauPrenom), "MONCOMPTE")
return self.index(message=u'Modification réussie')
changePrenomAdherent.exposed = True
##########################
# Adherent:tel
##########################
def changeTelAdherent(self, nouveauTel):
adh = cherrypy.session['LDAP'].search('uid=' + cherrypy.session['uid'], 'w')['adherent'][0]
try:
ancienTel = adh.tel()
adh.tel(nouveauTel)
adh.save()
except ValueError, e:
return self.index(error=e.args[0])
del adh
_crans_cp.log("Change tel : %s -> %s" % (ancienTel, nouveauTel), "MONCOMPTE")
return self.index(message=u'Modification réussie')
changeTelAdherent.exposed = True
##########################
# mail:alias:creation
##########################
def newAlias(self, alias):
adh = cherrypy.session['LDAP'].search('uid=' + cherrypy.session['uid'],'w')['adherent'][0]
if adh.alias().__len__() >= 3 and adh.droits() == []:
return self.index(error=u"Vous avez plus de 2 alias. Demander a un cableur pour en rajouter.")
try:
adh.alias(alias)
adh.save()
del adh
except ValueError, e:
return self.index(error=e.args[0])
except RuntimeError:
return self.index(error=u"Vous possèdez déjà  cet alias")
except EnvironmentError:
return self.index(error=u"Vous possèdez déjà  cet alias")
_crans_cp.log("Nouvel alias : %s" % alias, "MONCOMPTE")
return self.index(message=u'Alias enregistré')
newAlias.exposed = True
##########################
# mail:sauver
##########################
def saveMailPrefs(self, forwarding_address=None, spanTreatment=None, contourneGreylist=False, rewriteMailHeaders=False):
if spanTreatment == 'no':
spanTreatment = 'accepte'
if spanTreatment == 'mark':
spanTreatment = 'marque'
if spanTreatment == 'drop':
spanTreatment = 'supprime'
if contourneGreylist == 'oui':
contourneGreylist = True
if rewriteMailHeaders == 'oui':
rewriteMailHeaders = True
try:
adh = cherrypy.session['LDAP'].search('uid=' + cherrypy.session['uid'],'w')['adherent'][0]
if forwarding_address!=None:
MailConfig(cherrypy.session['uid'], forward=forwarding_address, spam=spanTreatment)
adh.contourneGreylist(contourneGreylist)
adh.rewriteMailHeaders(rewriteMailHeaders)
adh.save()
del adh
except ValueError, e:
return self.index(error=e.args[0])
except Exception, e:
return self.index(error=u"Une erreur est survenue lors de lenregistrement. Vérifiez que l'adresse mail fournie est correcte.")
_crans_cp.log("Change mail prefs", "MONCOMPTE ACTION")
return self.index(message=u'Vos préférences ont été enregistrées')
saveMailPrefs.exposed = True

View file

@ -0,0 +1,259 @@
/*
DOMtab Version 3.1415927
Updated March the First 2006
written by Christian Heilmann
check blog for updates: http://www.wait-till-i.com
free to use, not free to resell
*/
domtab={
tabClass:'domtab', // class to trigger tabbing
listClass:'domtabs', // class of the menus
activeClass:'active', // class of current link
contentElements:'div', // elements to loop through
backToLinks:/#top/, // pattern to check "back to top" links
printID:'domtabprintview', // id of the print all link
showAllLinkText:'show all content', // text for the print all link
prevNextIndicator:'doprevnext', // class to trigger prev and next links
prevNextClass:'prevnext', // class of the prev and next list
prevLabel:'previous', // HTML content of the prev link
nextLabel:'next', // HTML content of the next link
prevClass:'prev', // class for the prev link
nextClass:'next', // class for the next link
init:function(){
var temp;
if(!document.getElementById || !document.createTextNode){return;}
var tempelm=document.getElementsByTagName('div');
for(var i=0;i<tempelm.length;i++){
if(!domtab.cssjs('check',tempelm[i],domtab.tabClass)){continue;}
domtab.initTabMenu(tempelm[i]);
domtab.removeBackLinks(tempelm[i]);
if(domtab.cssjs('check',tempelm[i],domtab.prevNextIndicator)){
domtab.addPrevNext(tempelm[i]);
}
domtab.checkURL();
}
if(document.getElementById(domtab.printID)
&& !document.getElementById(domtab.printID).getElementsByTagName('a')[0]){
var newlink=document.createElement('a');
newlink.setAttribute('href','#');
domtab.addEvent(newlink,'click',domtab.showAll,false);
newlink.onclick=function(){return false;} // safari hack
newlink.appendChild(document.createTextNode(domtab.showAllLinkText));
document.getElementById(domtab.printID).appendChild(newlink);
}
},
checkURL:function(){
var id;
var loc=window.location.toString();
loc=/#/.test(loc)?loc.match(/#(\w.+)/)[1]:'';
if(loc==''){return;}
var elm=document.getElementById(loc);
if(!elm){return;}
var parentMenu=elm.parentNode.parentNode.parentNode;
parentMenu.currentSection=loc;
parentMenu.getElementsByTagName(domtab.contentElements)[0].style.display='none';
domtab.cssjs('remove',parentMenu.getElementsByTagName('a')[0].parentNode,domtab.activeClass);
var links=parentMenu.getElementsByTagName('a');
for(i=0;i<links.length;i++){
if(!links[i].getAttribute('href')){continue;}
if(!/#/.test(links[i].getAttribute('href').toString())){continue;}
id=links[i].href.match(/#(\w.+)/)[1];
if(id==loc){
var cur=links[i].parentNode.parentNode;
domtab.cssjs('add',links[i].parentNode,domtab.activeClass);
break;
}
}
domtab.changeTab(elm,1);
elm.focus();
cur.currentLink=links[i];
cur.currentSection=loc;
},
showAll:function(e){
document.getElementById(domtab.printID).parentNode.removeChild(document.getElementById(domtab.printID));
var tempelm=document.getElementsByTagName('div');
for(var i=0;i<tempelm.length;i++){
if(!domtab.cssjs('check',tempelm[i],domtab.tabClass)){continue;}
var sec=tempelm[i].getElementsByTagName(domtab.contentElements);
for(var j=0;j<sec.length;j++){
sec[j].style.display='block';
}
}
var tempelm=document.getElementsByTagName('ul');
for(i=0;i<tempelm.length;i++){
if(!domtab.cssjs('check',tempelm[i],domtab.prevNextClass)){continue;}
tempelm[i].parentNode.removeChild(tempelm[i]);
i--;
}
domtab.cancelClick(e);
},
addPrevNext:function(menu){
var temp;
var sections=menu.getElementsByTagName(domtab.contentElements);
for(var i=0;i<sections.length;i++){
temp=domtab.createPrevNext();
if(i==0){
temp.removeChild(temp.getElementsByTagName('li')[0]);
}
if(i==sections.length-1){
temp.removeChild(temp.getElementsByTagName('li')[1]);
}
temp.i=i; // h4xx0r!
temp.menu=menu;
sections[i].appendChild(temp);
}
},
removeBackLinks:function(menu){
var links=menu.getElementsByTagName('a');
for(var i=0;i<links.length;i++){
if(!domtab.backToLinks.test(links[i].href)){continue;}
links[i].parentNode.removeChild(links[i]);
i--;
}
},
initTabMenu:function(menu){
var id;
var lists=menu.getElementsByTagName('ul');
for(var i=0;i<lists.length;i++){
if(domtab.cssjs('check',lists[i],domtab.listClass)){
var thismenu=lists[i];
break;
}
}
if(!thismenu){return;}
thismenu.currentSection='';
thismenu.currentLink='';
var links=thismenu.getElementsByTagName('a');
for(i=0;i<links.length;i++){
if(!/#/.test(links[i].getAttribute('href').toString())){continue;}
id=links[i].href.match(/#(\w.+)/)[1];
if(document.getElementById(id)){
domtab.addEvent(links[i],'click',domtab.showTab,false);
links[i].onclick=function(){return false;} // safari hack
domtab.changeTab(document.getElementById(id),0);
}
}
id=links[0].href.match(/#(\w.+)/)[1];
if(document.getElementById(id)){
domtab.changeTab(document.getElementById(id),1);
thismenu.currentSection=id;
thismenu.currentLink=links[0];
domtab.cssjs('add',links[0].parentNode,domtab.activeClass);
}
},
createPrevNext:function(){
// this would be so much easier with innerHTML, darn you standards fetish!
var temp=document.createElement('ul');
temp.className=domtab.prevNextClass;
temp.appendChild(document.createElement('li'));
temp.getElementsByTagName('li')[0].appendChild(document.createElement('a'));
temp.getElementsByTagName('a')[0].setAttribute('href','#');
temp.getElementsByTagName('a')[0].innerHTML=domtab.prevLabel;
temp.getElementsByTagName('li')[0].className=domtab.prevClass;
temp.appendChild(document.createElement('li'));
temp.getElementsByTagName('li')[1].appendChild(document.createElement('a'));
temp.getElementsByTagName('a')[1].setAttribute('href','#');
temp.getElementsByTagName('a')[1].innerHTML=domtab.nextLabel;
temp.getElementsByTagName('li')[1].className=domtab.nextClass;
domtab.addEvent(temp.getElementsByTagName('a')[0],'click',domtab.navTabs,false);
domtab.addEvent(temp.getElementsByTagName('a')[1],'click',domtab.navTabs,false);
// safari fix
temp.getElementsByTagName('a')[0].onclick=function(){return false;}
temp.getElementsByTagName('a')[1].onclick=function(){return false;}
return temp;
},
navTabs:function(e){
var li=domtab.getTarget(e);
var menu=li.parentNode.parentNode.menu;
var count=li.parentNode.parentNode.i;
var section=menu.getElementsByTagName(domtab.contentElements);
var links=menu.getElementsByTagName('a');
var othercount=(li.parentNode.className==domtab.prevClass)?count-1:count+1;
section[count].style.display='none';
domtab.cssjs('remove',links[count].parentNode,domtab.activeClass);
section[othercount].style.display='block';
domtab.cssjs('add',links[othercount].parentNode,domtab.activeClass);
var parent=links[count].parentNode.parentNode;
parent.currentLink=links[othercount];
parent.currentSection=links[othercount].href.match(/#(\w.+)/)[1];
domtab.cancelClick(e);
},
changeTab:function(elm,state){
do{
elm=elm.parentNode;
} while(elm.nodeName.toLowerCase()!=domtab.contentElements)
elm.style.display=state==0?'none':'block';
},
showTab:function(e){
var o=domtab.getTarget(e);
if(o.parentNode.parentNode.currentSection!=''){
domtab.changeTab(document.getElementById(o.parentNode.parentNode.currentSection),0);
domtab.cssjs('remove',o.parentNode.parentNode.currentLink.parentNode,domtab.activeClass);
}
var id=o.href.match(/#(\w.+)/)[1];
o.parentNode.parentNode.currentSection=id;
o.parentNode.parentNode.currentLink=o;
domtab.cssjs('add',o.parentNode,domtab.activeClass);
domtab.changeTab(document.getElementById(id),1);
document.getElementById(id).focus();
domtab.cancelClick(e);
},
/* helper methods */
getTarget:function(e){
var target = window.event ? window.event.srcElement : e ? e.target : null;
if (!target){return false;}
if (target.nodeName.toLowerCase() != 'a'){target = target.parentNode;}
return target;
},
cancelClick:function(e){
if (window.event){
window.event.cancelBubble = true;
window.event.returnValue = false;
return;
}
if (e){
e.stopPropagation();
e.preventDefault();
}
},
addEvent: function(elm, evType, fn, useCapture){
if (elm.addEventListener)
{
elm.addEventListener(evType, fn, useCapture);
return true;
} else if (elm.attachEvent) {
var r = elm.attachEvent('on' + evType, fn);
return r;
} else {
elm['on' + evType] = fn;
}
},
cssjs:function(a,o,c1,c2){
switch (a){
case 'swap':
o.className=!domtab.cssjs('check',o,c1)?o.className.replace(c2,c1):o.className.replace(c1,c2);
break;
case 'add':
if(!domtab.cssjs('check',o,c1)){o.className+=o.className?' '+c1:c1;}
break;
case 'remove':
var rep=o.className.match(' '+c1)?' '+c1:c1;
o.className=o.className.replace(rep,'');
break;
case 'check':
var found=false;
var temparray=o.className.split(' ');
for(var i=0;i<temparray.length;i++){
if(temparray[i]==c1){found=true;}
}
return found;
break;
}
}
}
domtab.addEvent(window, 'load', domtab.init, false);
document.write('<style type="text/css">');
document.write('div.domtab>div{display:none;}<');
document.write('/s'+'tyle>');

Binary file not shown.

After

Width:  |  Height:  |  Size: 4 KiB

View file

@ -0,0 +1,368 @@
/********************************************
* <!-- disposition générale -->
********************************************/
#globalDiv {
padding-left:100px;
}
/* style du titre au dessus des onglet et des titres pour les pages PayPal */
div.domtab>h1,
h2 {
font-size:1.4em;
margin:2px;
}
/********************************************
* <!-- onglets -->
********************************************/
/* conteneur de l'ensemble */
div.domtab{
padding:3px;
width:100%;
background:#fad163;
clear:left;
}
/* onglets */
ul.domtabs{
float:left;
width:100%;
margin:0;
padding:0;
list-style-type:none;
}
ul.domtabs li{
float:left;
}
ul.domtabs a:link,
ul.domtabs a:visited,
ul.domtabs a:active,
ul.domtabs a:hover{
font-weight:bold;
display:block;
padding:0.4em;
text-align:center;
background:#fad163;
}
ul.domtabs li.active a:link,
ul.domtabs li.active a:visited,
ul.domtabs li.active a:active,
ul.domtabs li.active a:hover{
background:#fff7D7;
color:#000;
text-decoration:none;
}
/* les pages */
div.domtab>div {
padding:0;
clear:both;
border:5px solid #fff7D7;
}
/* ancre des pages */
.mark {
height:0;
clear:both;
display:none;
}
/********************************************
* <!-- division des pages -->
********************************************/
.tabbed_page {
padding:0;
margin:0;
}
ul.tabbed_page {
list-style-type:none;
}
dl.tabbed_page>dt,
dl.tabbed_page>dd,
ul.tabbed_page>li {
background:#fff7D7;
padding:10px;
margin:0 0 2px 0;
font-weight:bold;
}
dl.tabbed_page>dt.last,
dl.tabbed_page>dd.last,
ul.tabbed_page>li.last {
margin:0 0 0 0;
}
dl.tabbed_page>dt {
width:40%;
display:block;
height:100%;
float:left;
clear:left;
}
dl.tabbed_page>dd {
padding-left:45%;
}
span.actions {
display:block;
float:right;
font-size:0.9em;
font-weight:normal;
}
.tabbed_page span.actions a {
margin:2px 10px;
}
.tabbed_page dl,
.tabbed_page dl dt,
.tabbed_page dl dd {
margin:0;
padding:0;
}
.tabbed_page dl dt {
float:left;
margin-right:5px;
}
.tabbed_page dl dd,
.tabbed_page p {
font-weight:normal;
margin:3px;
}
span.valide {
color:green;
font-weight:bold;
}
span.invalide {
color:red;
font-weight:bold;
}
.clear {
clear:both;
}
ul.tabbed_page li.centrer {
padding:10px;
margin-left:0;
text-align:center;
}
/********************************************
* <!-- formulaires -->
********************************************/
.textInputNote {
display:block;
padding-left:0;
font-size:0.8em;
font-weight:normal;
}
dd .textInputNote {
padding-left:0;
}
li .textInputNote {
padding-left:175px;
}
label.textInputLabel{
width:175px;
display:block;
float:left;
}
label.checkBoxLabel{
float:none;
padding-left:175px;
}
/********************************************
* <!-- liste machines -->
********************************************/
dl#machineList,
dl#machineList>dt {
margin:0;
padding:0;
}
#machineList>dt {
font-size:1.2em;
font-weight:bold;
margin:5px 5px 5px 5px;
height:30px;
padding:10px 20px;
background:#fff7D7;
}
#machineList>dd {
margin:0 0 2px 0;
}
.linkToggle {
display:block;
float:left;
height:15px;
width:15px;
background:transparent url(../images/fl.png) top left;
margin-right:1px;
}
/********************************************
* <!-- infos machines -->
********************************************/
.machineDetails {
background: #fff7D7;/*/ url(../images/fondFacturesDetails.png) repeat-x top;*/
padding:0;
/*width:96%;*/
display:none;
margin:0;
}
dl.machineInfos dt, dl.machineInfos dd {
float:left;
margin-top:0;
padding:.1em;
display:block;
width:20%;
}
dl.machineInfos dt {
text-align:right;
width:20%;
}
/********************************************
* <!-- liste alias -->
********************************************/
ul.listeAlias {
list-style-type:none;
margin:0;
padding:0;
}
ul.listeAlias li span {
color:#666;
}
/********************************************
* <!-- messages -->
********************************************/
#loadings {
background:#cc0000;
position:fixed;
top:1px;
right:1px;
z-index:1000;
display:none;
padding:2px 3px;
color:white;
}
.messageText {
padding:2px 10px;
display:block;
}
#messagePlaceHolder {
height:0;
overflow:visible;
position:relative;
top:-4em;
}
.message {
padding:0;
background:#fad163;
width:300px;
text-align:center;
margin : 1px auto 10px auto;
}
.errorMessage {
display:block;
background:white;
border:2px #cc0000 solid;
padding:5px;
text-align:center;
min-width:230px;
max-width:430px;
font-weight:bold;
margin : 1px auto 10px auto;
}
/********************************************
* <!-- popup PayPal -->
********************************************/
div#popupInnerBody {
border:5px solid #fad163;
background: #fff7D7;
margin:5px;
padding:5px;
}
div#popupInnerBody .liens {
list-style-type:none;
float:right;
height:1em;
background: #fff7D7;
border-color:#fad163;
border-style: none solid solid solid;
border-width:3px;
margin:0;
padding:2px;
}
div#popupInnerBody .liens a {
display:block;
height:1em;
float : left;
margin:0 5px;
}
a { color:blue; }
/********************************************
* <!-- factures - details -->
********************************************/
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;
}
/********************************************
* divers
********************************************/
.empty {
color:gray;
}

View file

@ -0,0 +1,41 @@
function askForName(oldName) {
var c = '';
while ( c == '')
c = prompt("Votre nom :",oldName);
if (c == null)
return false;
else
window.location.href= 'changeNomAdherent?nouveauNom=' + c;
}
function askForSurname(oldSurname) {
var c = '';
while ( c == '')
c = prompt("Votre prénom :",oldSurname);
if (c == null)
return false;
else
window.location.href= 'changePrenomAdherent?nouveauPrenom=' + c;
}
function askForTel(oldTel) {
var c = '';
while ( c == '')
c = prompt("Votre numéro de téléphone :",oldTel);
if (c == null)
return false;
else
window.location.href= 'changeTelAdherent?nouveauTel=' + c;
}
function newAlias() {
var c = '';
while ( c == '')
c = prompt("Nouvel alias :");
if (c == null)
return false;
else
window.location.href= 'newAlias?alias=' + c + "#mailTab";
}

View file

@ -0,0 +1,66 @@
/************************************************************************
Password generator
************************************************************************/
function GeneratePassword() {
if (parseInt(navigator.appVersion) <= 3) {
alert("Sorry this only works in 4.0 browsers");
return false;
}
var length=8;
var sPassword = "";
length = 10;//document.aForm.charLen.options[document.aForm.charLen.selectedIndex].value;
var noPunction = false;//(document.aForm.punc.checked);
var randomLength = true;//(document.aForm.rLen.checked);
if (randomLength) {
length = Math.random();
length = parseInt(length * 100);
length = (length % 7) + 6
}
for (i=0; i < length; i++) {
numI = getRandomNum();
if (noPunction) { while (checkPunc(numI)) { numI = getRandomNum(); } }
sPassword = sPassword + String.fromCharCode(numI);
}
//document.aForm.passField.value = sPassword
c = prompt('Mot de passe généré : ', sPassword)
if (c!= null) {
document.changePasswordForm.nouveauPassword1.value = c
document.changePasswordForm.nouveauPassword2.value = c
}
return false;
}
function getRandomNum() {
// between 0 - 1
var rndNum = Math.random()
// rndNum from 0 - 1000
rndNum = parseInt(rndNum * 1000);
// rndNum from 33 - 127
rndNum = (rndNum % 94) + 33;
return rndNum;
}
function checkPunc(num) {
if ((num >=33) && (num <=47)) { return true; }
if ((num >=58) && (num <=64)) { return true; }
if ((num >=91) && (num <=96)) { return true; }
if ((num >=123) && (num <=126)) { return true; }
return false;
}

View file

@ -0,0 +1,22 @@
#import cherrypy
#set bugMail = cherrypy.config.get("mail.bugreport", "nounous@crans.org")
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" >
<head>
#include "inc-paypal-head.tmpl"
</head>
<body>
<div id="popupInnerBody">
<h2>Paiement annul&eacute;</h2>
<p>Ton compte impressions sera crédité d&eacute;s que la facture sera réglée.</p>
<p>Tu peux régler la facture plus tard en allant dans <a href="/sous/">Mes Factures</a></p>
<p>En cas de probl&egrave;me, envoie un mail &agrave; <a href="mailto:$bugMail">$bugMail</a></p>
<div class="liens">
<a href="./">Retour</a>
</div>
</div>
</form>
</div>
</body></html>

View file

@ -0,0 +1,21 @@
#import cherrypy
#set bugMail = cherrypy.config.get("mail.bugreport", "nounous@crans.org")
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" >
<head>
#include "inc-paypal-head.tmpl"
</head>
<body>
<div id="popupInnerBody">
<h2>Paiement termin&eacute;</h2>
<p>Ton compte impressions sera crédité dans quelques minutes.</p>
<p>N'h&eacute;site pas &agrave; nous envoyer tes remarques et/ou suggestions &agrave; <a href="mailto:$bugMail">$bugMail</a></p>
<div class="liens">
<a href="./">Retour</a>
</div>
</div>
</form>
</div>
</body></html>

View file

@ -0,0 +1,20 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" >
<head>
#include "inc-paypal-head.tmpl"
</head>
<body>
<div id="popupInnerBody">
<h2>Recharger son compte impression</h2>
<p> Le cr@ns te permet de recharger ton compte pour les impressions via PayPal ou en allant voir un c&acirc;bleur.</p>
<p>La m&eacute;thode PayPal est plus rapide mais PayPal facture des frais de transaction.</p>
<div class="liens">
<a href="./">Annuler</a>
<a href="?etape=2">Continuer avec Paypal</a>
</div>
</div>
</form>
</div>
</body></html>

View file

@ -0,0 +1,33 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" >
<head>
#include "inc-paypal-head.tmpl"
</head>
<body>
<div id="popupInnerBody">
<h2>&Eacute;tape 1 : Choisir le montant</h2>
#if $getVar('error',False)
<div class="errorMessage">$error</div>
#end if
<form method="post" action="rechargerCompteImpression" name="FormCombien">
<input type="hidden" name="etape" value="3" />
<label for="combien">Combien souhaites-tu mettre sur ton compte impression ?<br />
<input type="text" name="combien" value="$getVar('combien','')" /> &euro;
</label>
<p></p><!-- ici, calcul des frais de transaction -->
<div class="liens" id="liens">
<a href="./">Annuler</a>
<script type="text/JavaScript">
<!--
appendChildNodes("liens", A({'href':'#','onclick':"javascript:window.document.FormCombien.submit(); return false;"}, "Continuer"));
//-->
</script>
<noscript>
<input type="submit" value="Continuer"/>
</noscript>
</div>
</form>
</div>
</body></html>

View file

@ -0,0 +1,35 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" >
<head>
#include "inc-paypal-head.tmpl"
</head><body>
<div id="popupInnerBody">
<h2>&Eacute;tape 2 : Confirmer la facture</h2>
<table cellspacing="0" border="0" class="factureDetails">
<tr>
<th width="80%">Description</th>
<th>Prix unitaire</th>
<th>Quantit&eacute;</th>
<th>total</th>
</tr>
#for unDetail in $details
<tr>
<td>$unDetail.intitule</td>
<td>$unDetail.prixUnitaire&nbsp;&euro;</td>
<td>$unDetail.quantite</td>
<td>$unDetail.prixTotal&nbsp;&euro;</td>
</tr>
#end for
<tr>
<td colspan="3" class="tdTotalDetailIntitule">
Total
</td>
<td class="tdTotalDetail">$total&nbsp;&euro;</td>
</table>
<div class="liens">
<a href="?etape=2">Pr&eacute;c&eacute;dent</a>
<a href="./">Annuler</a>
<a href="?etape=4">Confirmer</a>
</div>
</div>
</body></html>

View file

@ -0,0 +1,15 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" >
<head>
#include "inc-paypal-head.tmpl"
</head><body>
<div id="popupInnerBody">
<h2>&Eacute;tape 3 : Fin</h2>
<p>Ton compte impressions sera crédité d&eacute;s que la facture sera réglée.</p>
<p>Tu peux régler la facture plus tard en allant dans <a href="/factures/">Mes Factures</a></p>
<div class="liens">
<a href="./">Payer plus tard</a>
<a href="$lienPaypal">Payer tout de suite</a>
</div>
</div>
</body></html>

View file

@ -0,0 +1,11 @@
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Cr@nsIntranet</title>
<!-- ++++++++++++++++++++++++++ stylesheets +++++++++++++++++++++++++++ -->
<link rel="stylesheet" type="text/css" href="$static('monCompte.css')" />
<!-- ++++++++++++++++++++++++++++ scripts +++++++++++++++++++++++++++++ -->
<script src="/static/MochiKit/MochiKit.js" type="text/javascript"></script>
<script src="/static/MochiKit/New.js" type="text/javascript"></script>

View file

@ -0,0 +1,211 @@
#if $message != ''
<script type="text/javascript">
<!--
Crans.messages.setMessage('$message.replace("\'","\\\'")')
//-->
</script>
#end if
#if $error != ''
<script type="text/javascript">
<!--
Crans.messages.setMessage('$error.replace("\'","\\\'")', 'errorMessage')
//-->
</script>
#end if
<div id="globalDiv">
<div id="paramCompte" class="domtab">
<h1>Param&egrave;tres de mon compte</h1>
<ul class="domtabs">
<li><a href="#mainTab">G&eacute;n&eacute;ral</a></li>
<li><a href="#mailTab">Mails</a></li>
</ul>
<!-- +++++++++++++++++++ Infos Utilisateur +++++++++++++++++++ -->
<div>
<h2 class="mark"><a name="mainTab" id="mainTab"></a></h2>
<dl class="tabbed_page">
<dt>Nom :</dt>
<dd>$adherent.nom
<span class="actions"><a href="#" onclick="return askForName('$adherent.nom')">modifier</a></span>
<div class="clear"></div>
</dd>
<dt>Pr&eacute;nom :</dt>
<dd>$adherent.prenom
<span class="actions"><a href="#" onclick="return askForSurname('$adherent.prenom')">modifier</a></span>
<div class="clear"></div>
</dd>
#if $getVar('adherent.adresse', False)
<dt>Adresse :</dt>
<dd>
$adherent.adresse.ligne1 <br />
#if $adherent.adresse.ligne2 != u' '
$adherent.adresse.ligne2 <br />
#end if
$adherent.adresse.cp $adherent.adresse.ville
</dd>
#else
<dt>Chambre :</dt>
<dd>$adherent.chambre</dd>
#end if
<dt>Solde :</dt>
<dd>
$adherent.solde &euro;
<span class="actions"><a href="rechargerCompteImpression" onclick="return paypalWindow('$adherent.telephone')">modifier</a></span>
<div class="clear"></div>
</dd>
<dt>T&eacute;l&eacute;phone :</dt>
<dd>$adherent.telephone
<span class="actions"><a href="#" onclick="return askForTel('$adherent.telephone')">modifier</a></span>
<div class="clear"></div>
</dd>
#if $adherent.droits
<dt>Droits :</dt>
<dd>
$adherent.droits
</dd>
#end if
<dt>&Eacute;tat administratif pour l'ann&eacute;e $adherent.anneeScolaire :</dt>
<dd>
<dl>
<dt>Cotisation : </dt>
<dd>
#if $adherent.cotisationOK
<span class="valide"> OK</span>
#else
<span class="invalide"> Non pay&eacute;e</span>
#end if
</dd>
<dt>Carte d'&eacute;tudiant : </dt>
<dd>
#if $adherent.carteOK
<span class="valide"> OK</span>
#else
<span class="invalide"> pas de carte d'&eacute;tudiant</span>
#end if
</dd>
</dl>
</dd>
<dt class="last">Changer mon mot de passe</dt>
<dd class="last">
<form action="changePasswordAdherent" name="changePasswordForm" method="post">
<div>
<label class="textInputLabel" for="ancienPassword">Ancien mot de passe : </label>
<input type="password" id="ancienPassword" name="ancienPassword"/><br />
<label class="textInputLabel" for="nouveauPassword1">Nouveau mot de passe : </label>
<input type="password" id="nouveauPassword1" name="nouveauPassword1"/><br />
<a class="textInputNote" href="#" onclick="return GeneratePassword()">Générer un nouveau mot de passe</a><br />
<label class="textInputLabel" for="nouveauPassword2">Confirmation : </label>
<input type="password" id="nouveauPassword2" name="nouveauPassword2"/><br />
<input type="submit" value="Modifier" />
</div>
</form>
</dd>
</dl>
</div>
<!-- +++++++++++++++++++ Infos Mails +++++++++++++++++++ -->
<div>
<h2 class="mark"><a name="mailTab" id="mailTab"></a></h2>
<form action="saveMailPrefs#mailTab" method="post">
<dl class="tabbed_page">
<dt>Alias:</dt>
<dd>
#if $mailInfos.alias==[]
<span class="empty">Vous n'avez pas d'alias</span>
#else
<ul class="listeAlias">
#for $an_alias in $mailInfos.alias
<li>$an_alias<span>@crans.org</span></li>
#end for
</ul>
#end if
<div class="clear"></div>
<span class="actions">
<a href="#" onclick="return newAlias()">Nouvel alias</a>
</span>
<div class="clear"></div>
</dd>
<dt> Greylisting: </dt>
<dd>
#if $mailInfos.contourneGreylist==True
<label for="contourneGreylist" class="labelCheckbox">
<input type="checkbox" name="contourneGreylist" id="contourneGreylist" class="inputCheckbox" value="oui" checked="checked" />
Contourner
</label>
#else
<label for="contourneGreylist" class="labelCheckbox">
<input type="checkbox" name="contourneGreylist" id="contourneGreylist" class="inputCheckbox" value="oui" />
Contourner
</label>
#end if
<a class="textInputNote" href="http://wiki/CransTechnique/GreyListing?highlight=%28Greylist%29" target="_blanc">Plus d'infos</a><br />
</dd>
<dt>
Ent&ecirc;tes:
</dt>
<dd>
#if $mailInfos.rewriteMailHeaders==True
<label for="rewriteMailHeaders" class="labelCheckbox">
<input type="checkbox" name="rewriteMailHeaders" id="rewriteMailHeaders" class="contourneGreylist" value="oui" checked="checked" />
R&eacute;&eacute;criture des en-t&ecirc;te mails
</label>
#else
<label for="rewriteMailHeaders" class="labelCheckbox">
<input type="checkbox" name="rewriteMailHeaders" id="rewriteMailHeaders" class="contourneGreylist" value="oui" />
R&eacute;&eacute;criture des en-t&ecirc;te mails
</label>
#end if
</dd>
</dl>
#if $getVar('mailError', False)
<ul class="tabbed_page">
<li class="centrer last">
<span class="errorMessage">$mailError</span>
</li>
</ul>
#else
<dl class="tabbed_page">
<dt>Transfert:</dt>
<dd>
<label for="forwarding_address" class="labelInput">
<input type="text" name="forwarding_address" id="forwarding_address" class="inputText" value="$mailInfos.forwarding_address" />
</label>
<p class="textInputNote">Laisser vide pour d&eacute;sactiver le transfert</p><br />
</dd>
<dt>Tri des spams:</dt>
<dd>
<label for="spanTreatment_no" class="labelRadio">
#if $mailInfos.spam.no
<input type="radio" name="spanTreatment" id="spanTreatment_no" class="inputRadio" value="no" checked="checked" /> Aucun
#else
<input type="radio" name="spanTreatment" id="spanTreatment_no" class="inputRadio" value="no" /> Aucun
#end if
</label><br />
<label for="spanTreatment_mark" class="labelRadio">
#if $mailInfos.spam.mark
<input type="radio" name="spanTreatment" id="spanTreatment_mark" class="inputRadio" value="mark" checked="checked" /> Marquer
#else
<input type="radio" name="spanTreatment" id="spanTreatment_mark" class="inputRadio" value="mark" /> Marquer
#end if
</label><br />
<label for="spanTreatment_drop" class="labelRadio">
#if $mailInfos.spam.drop
<input type="radio" name="spanTreatment" id="spanTreatment_drop" class="inputRadio" value="drop" checked="checked" /> Supprimer
#else
<input type="radio" name="spanTreatment" id="spanTreatment_drop" class="inputRadio" value="drop" /> Supprimer
#end if
</label><br />
</dd>
</dl>
#end if
<ul class="tabbed_page">
<li class="centrer last">
<input type="reset" value="Reset" />
<input type="submit" value="Soumettre" />
</li>
</ul>
</form>
</div>
</div>
</div>

107
intranet/modules/quota/main.py Executable file
View file

@ -0,0 +1,107 @@
#! /usr/bin/env python
import cherrypy, tempfile, shutil, os
import crans.utils.quota
import crans.cp
from ClassesIntranet.ModuleBase import ModuleBase
class main(ModuleBase):
def category(self):
return "Personnel"
def title(self):
return "Quotas"
def icon(self):
quotas = self._get_quota()
for a_quota in quotas:
if a_quota['quota'] < a_quota['usage']:
return "icon_alert.png"
return "icon.png"
def _get_quota(self):
#return quotas = crans.utils.quota.getUserQuota(cherrypy.session['uid'])
return [{'%': 33.9, 'quota': 390.62, 'label': u'Dossier personnel', 'limite': 585.94, 'filesystem': '/home', 'usage': 420.32}, {'%': 0.1, 'quota': 100.00, 'label': u'Boite de r\xe9ception', 'limite': 150.00, 'filesystem': '/var/mail', 'usage': 0.06}]
##########################
# affichage
##########################
#
# methode qui affiche la template
#
def index(self ):
values = {}
try:
quotas = self._get_quota()
returned_quotas = []
for a_quota in quotas:
# calculate text equivalent
quota = a_quota['quota']
usage = a_quota['usage']
limite = a_quota['limite']
text_equiv = "["
text_equiv+= "#" * min( 10, int( 10 * usage / quota ) )
text_equiv+= "." * max(0, int( 10 * ( quota - usage ) / quota ) )
if limite > quota:
text_equiv+= "|"
limite_diff = limite - quota
diff_proportion = 10 * limite_diff / quota
depassement = max(0, usage - quota)
text_equiv+= "#" * min(0, int(diff_proportion* ( depassement / limite_diff ) ) )
text_equiv+= "." * max(0, int(diff_proportion*( limite_diff - depassement ) / limite_diff ) )
text_equiv+= "]"
a_returned_quota = {
"label":a_quota['label'],
"usage":a_quota['usage'],
"quota":a_quota['quota'],
"limite":a_quota['limite'],
"percents":a_quota['%'],
"%":a_quota['%'],
"text_equiv":text_equiv,
"svg_url":"barreSVG?filesystem=%s" % a_quota['filesystem'],
}
returned_quotas.append(a_returned_quota)
values = {'quotas': returned_quotas, 'e': "eeede"}
except Exception, e:
crans.cp.log('error getting quota for user %s : %s' % (cherrypy.session['uid'], str(e)), 'QUOTA', 1)
values = {'erreur':str(e), 'e': "eee"}
return {'template':'quota',
'values': values,
'stylesheets':['quota.css'],
'scripts':['quota.js', 'popup.js'],
}
index.exposed = True
def index_html(self ):
result = self.index()
result['template'] = 'quota_html'
return result
index_html.exposed = True
##########################
# SVG
##########################
#
# methode qui renvoie une barre en svg
#
def barreSVG(self, filesystem = ""):
try:
values = {'erreur':"Not found"}
quotas = self._get_quota()
for a_quota in quotas:
if a_quota['filesystem'] == filesystem:
values = {
"usage":a_quota['usage'],
"quota":a_quota['quota'],
"limite":a_quota['limite'],
"percents":a_quota['%'],
}
except Exception, e:
values = {'erreur':str(e) }
cherrypy.response.headers['Content-Type']="image/svg+xml"
return {'template':'barre.svg',
'values': values,
'standalone':True,
}
barreSVG.exposed= True

Binary file not shown.

After

Width:  |  Height:  |  Size: 986 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

View file

@ -0,0 +1,40 @@
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="100%" height="100%" version="1.1" xmlns="http://www.w3.org/2000/svg">
#if $getVar('usage', False)
#set total = $limite
#set quota = $quota
#set usage = $usage
#set usage_percent = int( 100 * $usage/$limite )
#set quota_percent = int( 100 * $quota/$limite )
<defs>
<linearGradient id="barre_gradient" x1="0%" y1="0%" x2="100%" y2="0%">
<stop offset="0%" style="stop-color:rgb(0,255,0);stop-opacity:1"/>
<stop offset="$quota_percent%" style="stop-color:rgb(255,255,0);stop-opacity:1"/>
<stop offset="100%" style="stop-color:rgb(255,0,0);stop-opacity:1"/>
</linearGradient>
</defs>
<g font-family="Verdana" font-size="10">
<rect x="1" y="1" width="$total" height="22" style="fill:url(#barre_gradient);stroke:black;stroke-width:2;"/>
<line x1="$int(quota+2)" y1="15" x2="$int(quota+2)" y2="22" style="stroke:rgb(0,0,0);stroke-width:2"/>
<text x="2" y="40">0Mo</text>
<text x="$int(quota+2)" y="40">$int(quota) Mo</text>
<text x="$int(total+2)" y="40">$int(total) Mo</text>
</g>
<g font-family="Verdana" font-size="10">
<rect x="2" y="2" width="$usage" height="20" style="fill:white;opacity:0.7"/>
<line x1="$int(usage+2)" y1="2" x2="$int(usage+2)" y2="22" style="stroke:rgb(99,99,99);stroke-width:1"/>
<text x="4" y="15">$percents%</text>
</g>
#else
<g font-family="Verdana" font-size="10">
<text x="21" y="35" style="color:red">$getVar('erreur', 'BROKEN')</text>
</g>
#end if
</svg>

After

Width:  |  Height:  |  Size: 1.5 KiB

View file

@ -0,0 +1,13 @@
<div class="framed_gray">
#for un_truc in $quotas
<h3>$un_truc.label</h3>
<embed src="$un_truc.svg_url" width="100%" height="50"
type="image/svg+xml"
pluginspage="http://www.adobe.com/svg/viewer/install/" />
#end for
<div style="text-align:right;">Si les graphiques ne s'affichent pas, essayez la <a href="index_html">version html</a></div>
</div>

View file

@ -0,0 +1,22 @@
<div class="framed_gray">
#for un_truc in $quotas
<h3>$un_truc.label</h3>
#set total = $un_truc.limite
#set usage = int( 100 * $un_truc.usage/$un_truc.limite )
#set quota = int( 100 * $un_truc.quota/$un_truc.limite )
<div style="float:left;height:1.2em;width:40%;border:thin black solid;position:relative;background:#f99">
<div style="float:left;height:.8em;width:$usage%;background:blue;position:absolute;top:0;left:0;">
<span style="display:none">
$un_truc.text_equiv
</span>
</div>
<div style="float:left;height:1.2em;width:$quota%;background:#aaa"></div>
</div> $un_truc['%'] %
#end for
<div style="text-align:right;"><a href="index">version svg</a></div>
</div>