1 | """Users (principal) for the WAeUP portal. |
---|
2 | """ |
---|
3 | import grok |
---|
4 | from hurry import yui |
---|
5 | from waeup.authentication import Account |
---|
6 | from waeup.interfaces import IUserContainer |
---|
7 | from waeup.viewlets import LeftSidebar, MainArea, Index |
---|
8 | |
---|
9 | class UserContainer(grok.Container): |
---|
10 | """A container for principals. |
---|
11 | |
---|
12 | See interfaces.py and users.txt for extensive description. |
---|
13 | """ |
---|
14 | grok.implements(IUserContainer) |
---|
15 | grok.require('waeup.manageUsers') |
---|
16 | |
---|
17 | def addUser(self, name, password, title=None, description=None): |
---|
18 | if title is None: |
---|
19 | title = name |
---|
20 | if description is None: |
---|
21 | description = title |
---|
22 | self[name] = Account(name, password, title, description) |
---|
23 | |
---|
24 | def addAccount(self, account): |
---|
25 | self[account.name] = account |
---|
26 | |
---|
27 | def delUser(self, name): |
---|
28 | if name in self.keys(): |
---|
29 | del self[name] |
---|
30 | |
---|
31 | class UserContainerView(Index): |
---|
32 | grok.require('waeup.manageUsers') |
---|
33 | grok.context(IUserContainer) |
---|
34 | grok.name('index') |
---|
35 | |
---|
36 | def update(self): |
---|
37 | yui.sam.need() |
---|
38 | yui.datatable.need() |
---|
39 | |
---|
40 | def render(self, *args, **kw): |
---|
41 | return super(UserContainerView, self).render(*args, **kw) |
---|
42 | |
---|
43 | class UserContainerMain(grok.Viewlet): |
---|
44 | grok.require('waeup.manageUsers') |
---|
45 | grok.viewletmanager(MainArea) |
---|
46 | grok.template('usermain') |
---|
47 | grok.view(UserContainerView) |
---|
48 | |
---|