Project

General

Profile

Statistics
| Branch: | Tag: | Revision:

vigiboard / vigiboard / websetup.py @ 25892058

History | View | Annotate | Download (1.95 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 setup_app(command, conf, variables):
28
    """Place any commands to setup vigiboard here"""
29
    from vigilo.turbogears import populate_db as tg_pop_db
30
    from vigiboard.config.environment import load_environment
31

    
32
    load_environment(conf.global_conf, conf.local_conf)
33
    tg_pop_db()
34

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

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

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

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

    
50
    for (permission_name, description) in permissions.iteritems():
51
        if not tables.Permission.by_permission_name(unicode(permission_name)):
52
            DBSession.add(tables.Permission(
53
                permission_name=unicode(permission_name),
54
                description=unicode(description),
55
            ))
56
    DBSession.flush()