[intranet/quota] on arrête de planter bêtement lorsque l'utilisateur n'a pas de quota

darcs-hash:20090624081109-bd074-2ea69a8121de6b3a830a7b578341bfbbae828901.gz
This commit is contained in:
Antoine Durand-Gasselin 2009-06-24 10:11:09 +02:00
parent 776af42937
commit 8968220f87

View file

@ -12,24 +12,26 @@ class main(ModuleBase):
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"
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"):
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 ):
@ -68,24 +70,24 @@ class main(ModuleBase):
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',
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 = ""):
@ -103,7 +105,7 @@ class main(ModuleBase):
except Exception, e:
values = {'erreur':str(e) }
cherrypy.response.headers['Content-Type']="image/svg+xml"
return {'template':'barre.svg',
return {'template':'barre.svg',
'values': values,
'standalone':True,
}