vigiboard / vigiboard / controllers / vigiboard_plugin / shn.py @ 648f598d
History | View | Annotate | Download (1.96 KB)
1 |
# -*- coding: utf-8 -*-
|
---|---|
2 |
# vim:set expandtab tabstop=4 shiftwidth=4:
|
3 |
|
4 |
from vigiboard.controllers.vigiboard_plugin import \ |
5 |
VigiboardRequestPlugin
|
6 |
from vigiboard.model import DBSession, ServiceHautNiveau, Events, Service |
7 |
from sqlalchemy import sql, asc |
8 |
from pylons.i18n import ugettext as _ |
9 |
from tg import tmpl_context,config,url |
10 |
from tw.jquery.ui_dialog import JQueryUIDialog |
11 |
|
12 |
class PluginSHN (VigiboardRequestPlugin): |
13 |
|
14 |
"""
|
15 |
Plugin permettant de rajouter le nombre de SHNs impactés à
|
16 |
l'affichage
|
17 |
"""
|
18 |
|
19 |
def __init__(self): |
20 |
super(PluginSHN,self).__init__( |
21 |
table = [ServiceHautNiveau.servicename_dep, |
22 |
sql.func.count(Events.idevent)], |
23 |
outerjoin = [(ServiceHautNiveau, |
24 |
ServiceHautNiveau.servicename_dep == Events.servicename)], |
25 |
groupby = [(Events),(ServiceHautNiveau.servicename_dep)], |
26 |
name = _(u'SHNs impacté'),
|
27 |
style = {'title':u'Services de haut niveau impactés','style':'text-align:center'}, |
28 |
object_name = "shn"
|
29 |
) |
30 |
|
31 |
def show(self, req): |
32 |
"""Fonction d'affichage"""
|
33 |
if req[1] : |
34 |
return '<a href="javascript:vigiboard_shndialog(\'%s\',\'%d\')" class="SHNLien">%s</a>' % (url(''), req[0].idevent, req[2]) |
35 |
else :
|
36 |
return "" |
37 |
|
38 |
def context(self,context): |
39 |
"""Fonction de context"""
|
40 |
|
41 |
tmpl_context.shndialog = JQueryUIDialog(id='SHNDialog',
|
42 |
autoOpen=False,title='%s%s' % (_('Service de haut niveau'),' ')) |
43 |
context.append([tmpl_context.shndialog,self.object_name])
|
44 |
|
45 |
def controller(self,*argv,**krgv): |
46 |
idevent = krgv['idevent']
|
47 |
e = DBSession.query(Events.servicename).filter(Events.idevent == idevent) |
48 |
s = e.one().servicename |
49 |
e = DBSession.query(ServiceHautNiveau.servicename).filter(ServiceHautNiveau.servicename_dep == s) |
50 |
return dict( shns = [ee.servicename for ee in e]) |
51 |
|