Project

General

Profile

Statistics
| Branch: | Tag: | Revision:

vigiboard / vigiboard / websetup.py @ 6314d47e

History | View | Annotate | Download (2.21 KB)

1
# -*- coding: utf-8 -*-
2
################################################################################
3
#
4
# Copyright (C) 2007-2013 CS-SI
5
#
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
"""Setup the vigiboard application"""
21

    
22
# pylint: disable-msg=W0613
23
# W0613: Unused arguments: on doit respecter l'API
24

    
25
__all__ = ['setup_app', 'populate_db']
26

    
27
def dummy(msg):
28
    """
29
    Cette fonction n'est jamais exécutée.
30
    Elle permet simplement de forcer la traduction de
31
    chaînes provenant de vigilo-turbogears
32
    """
33
    _('Vigilo has detected a breakdown on the following '
34
      'collector(s): %(list)s')
35

    
36
def setup_app(command, conf, variables):
37
    """Place any commands to setup vigiboard here"""
38
    from vigilo.turbogears import populate_db as tg_pop_db
39
    from vigiboard.config.environment import load_environment
40

    
41
    load_environment(conf.global_conf, conf.local_conf)
42
    tg_pop_db()
43

    
44
def populate_db(bind):
45
    from vigilo.models.session import DBSession
46
    from vigilo.models import tables
47

    
48
    permissions = {
49
        'vigiboard-access':
50
            'Gives access to VigiBoard',
51

    
52
        'vigiboard-update':
53
            'Allows users to update events',
54

    
55
        'vigiboard-admin':
56
            'Allows users to forcefully close open events',
57
    }
58

    
59
    for (permission_name, description) in permissions.iteritems():
60
        if not tables.Permission.by_permission_name(unicode(permission_name)):
61
            DBSession.add(tables.Permission(
62
                permission_name=unicode(permission_name),
63
                description=unicode(description),
64
            ))
65
    DBSession.flush()