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