[Intranet] On désactive le module quota. Ah, et on committe les trucs que les autres n'ont pas commité.

Ignore-this: 57875a22b7c26a01dcd51b9331c93997

darcs-hash:20121031171234-b6762-b3c312f180024717569702a58bd59ed8a3cc0a83.gz
This commit is contained in:
Pierre-Elliott Bécue 2012-10-31 18:12:34 +01:00
parent 823e52de6c
commit a74d31de0e
9 changed files with 9 additions and 8 deletions

View file

@ -1,112 +0,0 @@
#! /usr/bin/env python
import cherrypy, tempfile, shutil, os
import crans.cp
from ClassesIntranet.ModuleBase import ModuleBase
import crans.utils.quota as quota
class main(ModuleBase):
_droits=["personnel"]
def category(self):
return "Personnel"
def title(self):
return "Quotas"
def icon(self):
try:
quotas = self._get_quota()
for a_quota in quotas:
if a_quota['quota'] < a_quota['usage']:
return "icon_alert.png"
return "icon.png"
except:
return "icon_disabled.png"
def _get_quota(self):
if (cherrypy.config.configMap["global"]["server.environment"] == "development"):
return quota.fake_getUserQuota(cherrypy.session['uid'])
else:
return quota.getUserQuota(cherrypy.session['uid'])
##########################
# 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}
except Exception, e:
crans.cp.log('error getting quota for user %s : %s' % (cherrypy.session['uid'], str(e)), 'QUOTA', 1)
values = {'erreur':str(e)}
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.

Before

Width:  |  Height:  |  Size: 986 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

View file

@ -1,43 +0,0 @@
<?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 barwidth = 700
#set quota = $quota
#set widthquota = int( barwidth * $quota/$limite )
#set widthusage = int( barwidth * $usage/$limite )
#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="$barwidth" height="22" style="fill:url(#barre_gradient);stroke:black;stroke-width:2;"/>
<line x1="$int(widthquota+2)" y1="15" x2="$int(widthquota+2)" y2="22" style="stroke:rgb(0,0,0);stroke-width:2"/>
<text x="2" y="40">0Mo</text>
<text x="$int(widthquota-15)" y="40">$int(quota) Mo</text>
<text x="$int(barwidth+5)" y="40">$int(total) Mo</text>
</g>
<g font-family="Verdana" font-size="10">
<rect x="2" y="2" width="$widthusage" height="20" style="fill:white;opacity:0.7"/>
<line x1="$int(widthusage+2)" y1="2" x2="$int(widthusage+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>

Before

Width:  |  Height:  |  Size: 1.7 KiB

View file

@ -1,13 +0,0 @@
<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

@ -1,22 +0,0 @@
<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>