author | Sylvain Thénault <sylvain.thenault@logilab.fr> |
Fri, 31 Jul 2009 10:42:15 +0200 | |
changeset 2585 | d84ea8753290 |
parent 2172 | cf8f9180e63e |
child 2920 | 64322aa83a1d |
permissions | -rw-r--r-- |
1977
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
1 |
"""cubicweb post creation script, set user's workflow |
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
2 |
|
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
3 |
:organization: Logilab |
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
4 |
:copyright: 2001-2009 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2. |
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
5 |
:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr |
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
6 |
:license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses |
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
7 |
""" |
0 | 8 |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
0
diff
changeset
|
9 |
activatedeid = add_state(_('activated'), 'CWUser', initial=True) |
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
0
diff
changeset
|
10 |
deactivatedeid = add_state(_('deactivated'), 'CWUser') |
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
0
diff
changeset
|
11 |
add_transition(_('deactivate'), 'CWUser', |
0 | 12 |
(activatedeid,), deactivatedeid, |
13 |
requiredgroups=('managers',)) |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
0
diff
changeset
|
14 |
add_transition(_('activate'), 'CWUser', |
0 | 15 |
(deactivatedeid,), activatedeid, |
16 |
requiredgroups=('managers',)) |
|
17 |
||
18 |
# need this since we already have at least one user in the database (the default admin) |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
0
diff
changeset
|
19 |
rql('SET X in_state S WHERE X is CWUser, S eid %s' % activatedeid) |
0 | 20 |
|
21 |
# create anonymous user if all-in-one config and anonymous user has been specified |
|
22 |
if hasattr(config, 'anonymous_user'): |
|
23 |
anonlogin, anonpwd = config.anonymous_user() |
|
24 |
if anonlogin: |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
0
diff
changeset
|
25 |
rql('INSERT CWUser X: X login %(login)s, X upassword %(pwd)s,' |
0 | 26 |
'X in_state S, X in_group G WHERE G name "guests", S name "activated"', |
27 |
{'login': unicode(anonlogin), 'pwd': anonpwd}) |
|
28 |
||
29 |
cfg = config.persistent_options_configuration() |
|
30 |
if interactive_mode: |
|
31 |
cfg.input_config(inputlevel=0) |
|
32 |
||
33 |
for section, options in cfg.options_by_section(): |
|
34 |
for optname, optdict, value in options: |
|
35 |
key = '%s.%s' % (section, optname) |
|
36 |
default = cfg.option_default(optname, optdict) |
|
37 |
# only record values differing from default |
|
38 |
if value != default: |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
0
diff
changeset
|
39 |
rql('INSERT CWProperty X: X pkey %(k)s, X value %(v)s', {'k': key, 'v': value}) |
0 | 40 |
|
41 |
# add PERM_USE_TEMPLATE_FORMAT permission |
|
42 |
from cubicweb.schema import PERM_USE_TEMPLATE_FORMAT |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
0
diff
changeset
|
43 |
eid = add_entity('CWPermission', name=PERM_USE_TEMPLATE_FORMAT, |
0 | 44 |
label=_('use template languages')) |
45 |
rql('SET X require_group G WHERE G name "managers", X eid %(x)s', |
|
2172
cf8f9180e63e
delete-trailing-whitespace
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
1977
diff
changeset
|
46 |
{'x': eid}, 'x') |