Project

General

Profile

Statistics
| Branch: | Tag: | Revision:

vigiboard / vigiboard / websetup.py @ 011743be

History | View | Annotate | Download (1.88 KB)

1
# -*- coding: utf-8 -*-
2
# Copyright (C) 2007-2020 CS GROUP - France
3
# License: GNU GPL v2 <http://www.gnu.org/licenses/gpl-2.0.html>
4

    
5
"""Setup the vigiboard application"""
6

    
7
# pylint: disable-msg=W0613
8
# W0613: Unused arguments: on doit respecter l'API
9

    
10
import imp
11

    
12
__all__ = ['setup_app', 'populate_db']
13

    
14
def _(msg):
15
    """
16
    Cette fonction n'est jamais exécutée.
17
    Elle permet simplement de forcer la traduction de
18
    chaînes provenant de vigilo-turbogears
19
    """
20
    _('Vigilo has detected a breakdown on the following '
21
      'collector(s): %(list)s')
22

    
23
def setup_app(command, conf, variables):
24
    """Place any commands to setup vigiboard here"""
25
    from vigilo.turbogears import populate_db as tg_pop_db
26

    
27
    # Charge le fichier "app_cfg.py" se trouvant aux côtés de "settings.ini".
28
    mod_info = imp.find_module('app_cfg', [ conf.global_conf['here'] ])
29
    app_cfg = imp.load_module('vigiboard.config.app_cfg', *mod_info)
30

    
31
    # Initialisation de l'environnement d'exécution.
32
    load_environment = app_cfg.base_config.make_load_environment()
33
    load_environment(conf.global_conf, conf.local_conf)
34
    tg_pop_db()
35

    
36
def populate_db(bind):
37
    from vigilo.models.session import DBSession
38
    from vigilo.models import tables
39

    
40
    permissions = {
41
        'vigiboard-access':
42
            'Gives access to VigiBoard',
43

    
44
        'vigiboard-update':
45
            'Allows users to update events',
46

    
47
        'vigiboard-admin':
48
            'Allows users to forcefully close open events',
49

    
50
        'vigiboard-silence':
51
            'Allows users to view and edit silence rules',
52
    }
53

    
54
    for (permission_name, description) in permissions.iteritems():
55
        if not tables.Permission.by_permission_name(unicode(permission_name)):
56
            DBSession.add(tables.Permission(
57
                permission_name=unicode(permission_name),
58
                description=unicode(description),
59
            ))
60
    DBSession.flush()