Changeset 4111 for waeup/branches


Ignore:
Timestamp:
6 May 2009, 06:51:47 (16 years ago)
Author:
uli
Message:

Add edit view for single users.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • waeup/branches/ulif-rewrite/src/waeup/users.py

    r4104 r4111  
    1 """Users (principal) for the WAeUP portal.
     1"""Users (principals) for the WAeUP portal.
    22"""
    33import grok
    44from hurry import yui
    55from waeup.authentication import Account
    6 from waeup.interfaces import IUserContainer
    7 from waeup.viewlets import LeftSidebar, MainArea, Index
     6from waeup.interfaces import IUserContainer, IUserAccount
     7from waeup.viewlets import LeftSidebar, MainArea, Index, Manage, FormWrapMixin
    88
    99class UserContainer(grok.Container):
     
    3434    grok.name('index')
    3535   
    36     def update(self):
     36    def update(self, userid=None, adduser=None, edit=None, delete=None):
    3737        yui.sam.need()
    3838        yui.datatable.need()
     39
     40        if edit is not None and userid is not None:
     41            self.redirect(self.url(userid))
    3942       
    4043    def render(self, *args, **kw):
     
    4750    grok.view(UserContainerView)
    4851
     52
     53class UserEditForm(grok.EditForm):
     54    grok.context(IUserAccount)
     55    form_fields = grok.AutoFields(IUserAccount)
     56    grok.require('waeup.manageUsers')   
     57
     58    @grok.action('Save')
     59    def save(self, **data):
     60        self.applyData(self.context, **data)
     61        self.flash('User was modified.')
     62        return
     63   
     64    @grok.action('Save and return')
     65    def saveAndReturn(self, **data):
     66        self.applyData(self.context, **data)
     67        self.flash('User was modified.')
     68        self.redirect(self.url(self.context.__parent__))
     69        return
     70
     71    @grok.action('Cancel')
     72    def cancel(self, **data):
     73        self.redirect(self.url(self.context.__parent__))
     74        return
     75
     76
     77class UserEditMain(FormWrapMixin, grok.Viewlet):
     78    """A viewlet that renders the `UserEditForm`.
     79    """
     80    grok.viewletmanager(MainArea)
     81    grok.context(IUserAccount)
     82    grok.view(Index)
     83    grok.require('waeup.manageUsers')
     84   
     85    formview_name = 'usereditform' # The name of the formview we want to
     86                                   # be rendered in this viewlet.
Note: See TracChangeset for help on using the changeset viewer.