Revision b8500d1a
Amélioration Pylint
git-svn-id: https://vigilo-dev.si.c-s.fr/svn@599 b22e2e97-25c9-44ff-b637-2e5ceca36478
vigiboard/controllers/vigiboard_plugin/shn.py | ||
---|---|---|
1 | 1 |
# -*- coding: utf-8 -*- |
2 | 2 |
# vim:set expandtab tabstop=4 shiftwidth=4: |
3 |
""" |
|
4 |
Plugin SHN : High level service |
|
5 |
""" |
|
3 | 6 |
|
4 | 7 |
from vigiboard.controllers.vigiboard_plugin import \ |
5 | 8 |
VigiboardRequestPlugin |
6 |
from vigiboard.model import DBSession, ServiceHautNiveau, Events, Service
|
|
7 |
from sqlalchemy import sql, asc
|
|
9 |
from vigiboard.model import DBSession, ServiceHautNiveau, Events |
|
10 |
from sqlalchemy import sql |
|
8 | 11 |
from pylons.i18n import ugettext as _ |
9 |
from tg import tmpl_context,config,url
|
|
12 |
from tg import tmpl_context, url
|
|
10 | 13 |
from tw.jquery.ui_dialog import JQueryUIDialog |
11 | 14 |
|
12 | 15 |
class PluginSHN (VigiboardRequestPlugin): |
... | ... | |
17 | 20 |
""" |
18 | 21 |
|
19 | 22 |
def __init__(self): |
20 |
super(PluginSHN,self).__init__( |
|
23 |
super(PluginSHN, self).__init__(
|
|
21 | 24 |
table = [ServiceHautNiveau.servicename_dep, |
22 | 25 |
sql.func.count(Events.idevent)], |
23 | 26 |
outerjoin = [(ServiceHautNiveau, |
24 | 27 |
ServiceHautNiveau.servicename_dep == Events.servicename)], |
25 | 28 |
groupby = [(Events),(ServiceHautNiveau.servicename_dep)], |
26 | 29 |
name = _(u'SHNs impacté'), |
27 |
style = {'title':u'Services de haut niveau impactés','style':'text-align:center'}, |
|
30 |
style = {'title': u'Services de haut niveau impactés', |
|
31 |
'style': 'text-align:center'}, |
|
28 | 32 |
object_name = "shn" |
29 | 33 |
) |
30 | 34 |
|
31 | 35 |
def show(self, req): |
32 | 36 |
"""Fonction d'affichage""" |
33 | 37 |
if req[1] : |
34 |
return '<a href="javascript:vigiboard_shndialog(\'%s\',\'%d\')" class="SHNLien">%s</a>' % (url(''), req[0].idevent, req[2]) |
|
38 |
return '<a href="javascript:vigiboard_shndialog(\'%s\',\'%d\')"' + \ |
|
39 |
' class="SHNLien">%s</a>' % (url(''), req[0].idevent, req[2]) |
|
35 | 40 |
else : |
36 | 41 |
return "" |
37 | 42 |
|
38 |
def context(self,context): |
|
43 |
def context(self, context):
|
|
39 | 44 |
"""Fonction de context""" |
40 | 45 |
|
41 | 46 |
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]) |
|
47 |
autoOpen=False, title='%s%s' % (_('Service de haut niveau'), |
|
48 |
' ')) |
|
49 |
context.append([tmpl_context.shndialog, self.object_name]) |
|
44 | 50 |
|
45 |
def controller(self,*argv,**krgv): |
|
51 |
def controller(self, *argv, **krgv): |
|
52 |
"""Ajout de fonctionnalités au controlleur""" |
|
46 | 53 |
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]) |
|
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]) |
|
51 | 60 |
|
Also available in: Unified diff