Changeset 4113 for waeup/branches/ulif-rewrite/src
- Timestamp:
- 6 May 2009, 07:22:44 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
waeup/branches/ulif-rewrite/src/waeup/users.py
r4111 r4113 3 3 import grok 4 4 from hurry import yui 5 from zope.exceptions import DuplicationError 5 6 from waeup.authentication import Account 6 7 from waeup.interfaces import IUserContainer, IUserAccount 7 from waeup.viewlets import LeftSidebar, MainArea, Index, Manage, FormWrapMixin8 from waeup.viewlets import LeftSidebar, MainArea, Index, Add, FormWrapMixin 8 9 9 10 class UserContainer(grok.Container): … … 43 44 def render(self, *args, **kw): 44 45 return super(UserContainerView, self).render(*args, **kw) 45 46 47 class AddUserForm(grok.AddForm): 48 grok.require('waeup.manageUsers') 49 grok.context(UserContainer) 50 form_fields = grok.AutoFields(IUserAccount) 51 label = 'Add user' 52 53 @grok.action('Add user') 54 def addFaculty(self, **data): 55 #user = Account(**data) 56 name = data['name'] 57 title = data['title'] 58 description = data['description'] 59 password = data['password'] 60 try: 61 self.context.addUser(name, password, title=title, 62 description=description) 63 except DuplicationError: 64 self.status = Invalid('The userid chosen already exists ' 65 'in the database') 66 return 67 self.redirect(self.url(self.context)) 68 69 class AddUser(FormWrapMixin, grok.Viewlet): 70 """A viewlet that wraps the `AddUserForm`. 71 """ 72 grok.viewletmanager(MainArea) 73 grok.context(UserContainer) 74 grok.view(Add) 75 grok.require('waeup.manageUsers') 76 77 formview_name = 'adduserform' # The name of the formview we want 78 # to be rendered in this viewlet. 79 46 80 class UserContainerMain(grok.Viewlet): 47 81 grok.require('waeup.manageUsers')
Note: See TracChangeset for help on using the changeset viewer.