Skip to content

Commit 3cb2a31

Browse files
author
Richard Jones
committed
more upgrading docco and a tool to fix roles
1 parent d78921e commit 3cb2a31

File tree

2 files changed

+65
-0
lines changed

2 files changed

+65
-0
lines changed

doc/upgrading.txt

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ to::
162162

163163
noting that your definition of the nosy Multilink will override the normal one.
164164

165+
165166
0.5.0 User schema changes
166167
~~~~~~~~~~~~~~~~~~~~~~~~~
167168

@@ -298,6 +299,30 @@ You may verify the setup of Permissions and Roles using the new
298299
"``roundup-admin security``" command.
299300

300301

302+
0.5.0 User changes
303+
~~~~~~~~~~~~~~~~~~
304+
305+
To support all those schema changes, you'll need to massage your user database
306+
a little too, to:
307+
308+
1. make sure there's an "anonymous" user - this user is mandatory now and is
309+
the one that unknown users are logged in as.
310+
2. make sure all users have at least one Role.
311+
312+
If you don't have the "anonymous" user, create it now with the command::
313+
314+
roundup-admin create user username=anonymous roles=Anonymous
315+
316+
making sure the capitalisation is the same as above. Once you've done that,
317+
you'll need to set the roles property on all users to a reasonable default.
318+
The admin user should get "Admin", the anonymous user "Anonymous"
319+
and all other users "User". The ``fixroles.py`` script in the tools directory
320+
will do this. Run it like so (where python is your python 2+ binary)::
321+
322+
python tools/fixroles.py -i <instance home>
323+
324+
325+
301326
0.5.0 CGI interface changes
302327
---------------------------
303328

tools/fixroles.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import sys
2+
3+
from roundup import admin
4+
5+
class AdminTool(admin.AdminTool):
6+
def __init__(self):
7+
self.commands = admin.CommandDict()
8+
for k in AdminTool.__dict__.keys():
9+
if k[:3] == 'do_':
10+
self.commands[k[3:]] = getattr(self, k)
11+
self.help = {}
12+
for k in AdminTool.__dict__.keys():
13+
if k[:5] == 'help_':
14+
self.help[k[5:]] = getattr(self, k)
15+
self.instance_home = ''
16+
self.db = None
17+
18+
def do_fixroles(self, args):
19+
'''Usage: fixroles
20+
Set the roles property for all users to reasonable defaults.
21+
22+
The admin user gets "Admin", the anonymous user gets "Anonymous"
23+
and all other users get "User".
24+
'''
25+
# get the user class
26+
cl = self.get_class('user')
27+
for userid in cl.list():
28+
username = cl.get(userid, 'username')
29+
if username == 'admin':
30+
roles = 'Admin'
31+
elif username == 'anonymous':
32+
roles = 'Anonymous'
33+
else:
34+
roles = 'User'
35+
cl.set(userid, roles=roles)
36+
return 0
37+
38+
if __name__ == '__main__':
39+
tool = AdminTool()
40+
sys.exit(tool.main())

0 commit comments

Comments
 (0)