Revision 10848680
Utilsation des fonctionnalités fournies par vigilo-turbogears pour la config et la création des tables.
Quelques corrections mineures.
git-svn-id: https://vigilo-dev.si.c-s.fr/svn@950 b22e2e97-25c9-44ff-b637-2e5ceca36478
vigiboard/websetup.py | ||
---|---|---|
7 | 7 |
from tg import config |
8 | 8 |
|
9 | 9 |
from vigiboard.config.environment import load_environment |
10 |
from vigilo.turbogears import populate_db |
|
10 | 11 |
|
11 | 12 |
__all__ = ['setup_app'] |
12 | 13 |
|
... | ... | |
16 | 17 |
def setup_app(command, conf, variables): |
17 | 18 |
"""Place any commands to setup vigiboard here""" |
18 | 19 |
load_environment(conf.global_conf, conf.local_conf) |
20 |
populate_db() |
|
19 | 21 |
|
20 |
# Load the models |
|
21 |
from vigiboard import model |
|
22 |
|
|
23 |
# Create tables |
|
24 |
print "Creating tables" |
|
25 |
model.metadata.create_all() |
|
26 |
|
|
27 |
# Create a test used called "manager". |
|
28 |
manager = model.User() |
|
29 |
manager.user_name = u'manager' |
|
30 |
manager.email = u'manager@somedomain.com' |
|
31 |
model.DBSession.add(manager) |
|
32 |
|
|
33 |
# Create a test group called "managers" |
|
34 |
# and add "manager" to that group. |
|
35 |
group = model.UserGroup() |
|
36 |
group.group_name = u'managers' |
|
37 |
group.users.append(manager) |
|
38 |
model.DBSession.add(group) |
|
39 |
|
|
40 |
# Create a test permission called "manage" |
|
41 |
# and give it to the group of "managers". |
|
42 |
permission = model.Permission() |
|
43 |
permission.permission_name = u'manage' |
|
44 |
permission.usergroups.append(group) |
|
45 |
model.DBSession.add(permission) |
|
46 |
|
|
47 |
# Create a test user called "editor". |
|
48 |
editor = model.User() |
|
49 |
editor.user_name = u'editor' |
|
50 |
editor.email = u'editor@somedomain.com' |
|
51 |
model.DBSession.add(editor) |
|
52 |
|
|
53 |
# Create a test group called "editors" |
|
54 |
# and add "editor" to that group. |
|
55 |
group = model.UserGroup() |
|
56 |
group.group_name = u'editors' |
|
57 |
group.users.append(editor) |
|
58 |
model.DBSession.add(group) |
|
59 |
|
|
60 |
# Create a test permission called "edit" |
|
61 |
# and give it to the group of "editors". |
|
62 |
permission = model.Permission() |
|
63 |
permission.permission_name = u'edit' |
|
64 |
permission.usergroups.append(group) |
|
65 |
model.DBSession.add(permission) |
|
66 |
|
|
67 |
version = model.Version() |
|
68 |
version.name = u'vigiboard' |
|
69 |
version.version = config['vigiboard_version'] |
|
70 |
model.DBSession.add(version) |
|
71 |
|
|
72 |
model.DBSession.flush() |
|
73 |
transaction.commit() |
|
74 |
print "Successfully setup" |
Also available in: Unified diff