Mercurial > p > roundup > code
view tools/fixroles.py @ 7971:fe0348bbe45b
issue2551353 - Add roundup-classhelper for 2.4.0 release
Changes to the classic template are not done yet. Still testing.
This commit has document updates and changes to rest.py.
rest.py:
add /rest/data/user/role endpoint to core so the user doesn't have
to add the /rest/roles endpoint via interfaces.py. It will only send
roles for a user with Admin role and there is no way to override
this currently.
acknowledgements.txt:
Added members of team3 to other contributors. Specified for all
other contributes what they worked on.
upgrading.txt:
added classhelper section and basic template change
directions. Linked to admin_guide for full directions.
admin_guide.txt:
documented install, translation, troubleshooting, config etc.
user_guide.txt:
added section on using the classhelper. Added reference to section
earlier in the doc. Added image for section.
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Tue, 21 May 2024 01:17:28 -0400 |
| parents | 52c8324d1539 |
| children |
line wrap: on
line source
import sys from roundup import admin class AdminTool(admin.AdminTool): def __init__(self): self.commands = admin.CommandDict() for k in AdminTool.__dict__.keys(): if k[:3] == 'do_': self.commands[k[3:]] = getattr(self, k) self.help = {} for k in AdminTool.__dict__.keys(): if k[:5] == 'help_': self.help[k[5:]] = getattr(self, k) self.instance_home = '' self.db = None def do_fixroles(self, args): '''Usage: fixroles Set the roles property for all users to reasonable defaults. The admin user gets "Admin", the anonymous user gets "Anonymous" and all other users get "User". ''' # get the user class cl = self.get_class('user') for userid in cl.list(): username = cl.get(userid, 'username') if username == 'admin': roles = 'Admin' elif username == 'anonymous': roles = 'Anonymous' else: roles = 'User' cl.set(userid, roles=roles) return 0 if __name__ == '__main__': tool = AdminTool() sys.exit(tool.main())
