Project

General

Profile

Statistics
| Branch: | Tag: | Revision:

vigiboard / vigiboard / websetup.py @ d3c47597

History | View | Annotate | Download (1.88 KB)

1
# -*- coding: utf-8 -*-
2
"""Setup the vigiboard application"""
3

    
4
import logging
5

    
6
import transaction
7
from tg import config
8

    
9
from vigiboard.config.environment import load_environment
10

    
11
__all__ = ['setup_app']
12

    
13
log = logging.getLogger(__name__)
14

    
15

    
16
def setup_app(command, conf, variables):
17
    """Place any commands to setup vigiboard here"""
18
    load_environment(conf.global_conf, conf.local_conf)
19

    
20
    # Load the models
21
    from vigiboard import model
22

    
23
    # Create tables
24
    print "Creating tables"
25
    model.metadata.create_all()
26
    print "Successfully created tables"
27

    
28
    # Create a test used called "manager".
29
    manager = model.User()
30
    manager.user_name = u'manager'
31
    manager.email = u'manager@somedomain.com'
32
    model.DBSession.add(manager)
33

    
34
    # Create a test group called "managers"
35
    # and add "manager" to that group.
36
    group = model.UserGroup()
37
    group.group_name = u'managers'
38
    group.users.append(manager)
39
    model.DBSession.add(group)
40

    
41
    # Create a test permission called "manage"
42
    # and give it to the group of "managers".
43
    permission = model.Permission()
44
    permission.permission_name = u'manage'
45
    permission.usergroups.append(group)
46
    model.DBSession.add(permission)
47

    
48
    # Create a test user called "editor".
49
    editor = model.User()
50
    editor.user_name = u'editor'
51
    editor.email = u'editor@somedomain.com'
52
    model.DBSession.add(editor)
53

    
54
    # Create a test group called "editors"
55
    # and add "editor" to that group.
56
    group = model.UserGroup()
57
    group.group_name = u'editors'
58
    group.users.append(editor)
59
    model.DBSession.add(group)
60

    
61
    # Create a test permission called "edit"
62
    # and give it to the group of "editors".
63
    permission = model.Permission()
64
    permission.permission_name = u'edit'
65
    permission.usergroups.append(group)
66
    model.DBSession.add(permission)
67

    
68
    model.DBSession.flush()
69
    transaction.commit()
70
    print "Successfully setup"