vigiboard / vigiboard / websetup.py @ b82c4c03
History | View | Annotate | Download (2.58 KB)
1 | 57f7cb3f | Gabriel DE PERTHUIS | # -*- coding: utf-8 -*-
|
---|---|---|---|
2 | a77de887 | Francois POIROTTE | ################################################################################
|
3 | #
|
||
4 | 8d647d93 | Francois POIROTTE | # Copyright (C) 2007-2015 CS-SI
|
5 | a77de887 | Francois POIROTTE | #
|
6 | # This program is free software; you can redistribute it and/or modify
|
||
7 | # it under the terms of the GNU General Public License version 2 as
|
||
8 | # published by the Free Software Foundation.
|
||
9 | #
|
||
10 | # This program is distributed in the hope that it will be useful,
|
||
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
13 | # GNU General Public License for more details.
|
||
14 | #
|
||
15 | # You should have received a copy of the GNU General Public License
|
||
16 | # along with this program; if not, write to the Free Software
|
||
17 | # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||
18 | ################################################################################
|
||
19 | |||
20 | 57f7cb3f | Gabriel DE PERTHUIS | """Setup the vigiboard application"""
|
21 | |||
22 | 8b2edebe | Aurelien BOMPARD | # pylint: disable-msg=W0613
|
23 | # W0613: Unused arguments: on doit respecter l'API
|
||
24 | |||
25 | b82c4c03 | Francois POIROTTE | import imp |
26 | |||
27 | d9669e56 | Francois POIROTTE | __all__ = ['setup_app', 'populate_db'] |
28 | 57f7cb3f | Gabriel DE PERTHUIS | |
29 | ac065134 | Francois POIROTTE | def _(msg): |
30 | 6314d47e | Vincent QUEMENER | """
|
31 | Cette fonction n'est jamais exécutée.
|
||
32 | Elle permet simplement de forcer la traduction de
|
||
33 | chaînes provenant de vigilo-turbogears
|
||
34 | """
|
||
35 | _('Vigilo has detected a breakdown on the following '
|
||
36 | 'collector(s): %(list)s')
|
||
37 | |||
38 | d3c47597 | Francois POIROTTE | def setup_app(command, conf, variables): |
39 | 57f7cb3f | Gabriel DE PERTHUIS | """Place any commands to setup vigiboard here"""
|
40 | f4573e92 | Francois POIROTTE | from vigilo.turbogears import populate_db as tg_pop_db |
41 | d9669e56 | Francois POIROTTE | |
42 | b82c4c03 | Francois POIROTTE | # Charge le fichier "app_cfg.py" se trouvant aux côtés de "settings.ini".
|
43 | mod_info = imp.find_module('app_cfg', [ conf.global_conf['here'] ]) |
||
44 | app_cfg = imp.load_module('vigiboard.config.app_cfg', *mod_info)
|
||
45 | |||
46 | # Initialisation de l'environnement d'exécution.
|
||
47 | load_environment = app_cfg.base_config.make_load_environment() |
||
48 | 57f7cb3f | Gabriel DE PERTHUIS | load_environment(conf.global_conf, conf.local_conf) |
49 | f4573e92 | Francois POIROTTE | tg_pop_db() |
50 | d3c47597 | Francois POIROTTE | |
51 | d9669e56 | Francois POIROTTE | def populate_db(bind): |
52 | from vigilo.models.session import DBSession |
||
53 | from vigilo.models import tables |
||
54 | |||
55 | dadde4eb | Francois POIROTTE | permissions = { |
56 | 'vigiboard-access':
|
||
57 | 'Gives access to VigiBoard',
|
||
58 | |||
59 | 'vigiboard-update':
|
||
60 | 'Allows users to update events',
|
||
61 | |||
62 | 'vigiboard-admin':
|
||
63 | 'Allows users to forcefully close open events',
|
||
64 | d5a41c9b | Vincent QUEMENER | |
65 | 'vigiboard-silence':
|
||
66 | 'Allows users to view and edit silence rules',
|
||
67 | dadde4eb | Francois POIROTTE | } |
68 | |||
69 | for (permission_name, description) in permissions.iteritems(): |
||
70 | if not tables.Permission.by_permission_name(unicode(permission_name)): |
||
71 | DBSession.add(tables.Permission( |
||
72 | ffa36417 | Francois POIROTTE | permission_name=unicode(permission_name),
|
73 | description=unicode(description),
|
||
74 | dadde4eb | Francois POIROTTE | )) |
75 | d9669e56 | Francois POIROTTE | DBSession.flush() |