Ignore:
Timestamp:
1 Apr 2009, 15:35:32 (16 years ago)
Author:
uli
Message:

Make faculties managable.

File:
1 edited

Legend:

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

    r3926 r4038  
    11import grok
    22from waeup.interfaces import IFaculty
    3 from waeup.viewlets import MainArea, LeftSidebar, Index, FormWrapMixin
     3from waeup.viewlets import MainArea, LeftSidebar, Index, FormWrapMixin, Manage
    44
    55class Faculty(grok.Container):
     
    2626
    2727grok.global_utility(Faculty, provides=IFaculty)
     28
     29
     30class ManageForm(grok.EditForm):
     31    """Manage the basic properties of a `Faculty` instance.
     32    """
     33
     34    form_fields = grok.AutoFields(IFaculty)
     35
     36    @property
     37    def label(self):
     38        # Set faculty name as form label
     39        return self.form_fields['name'].field.get(self.context)
     40   
     41    @grok.action('Save')
     42    def save(self, **data):
     43        self.applyData(self.context, **data)
     44        return
     45   
     46    @grok.action('Save and return')
     47    def saveAndReturn(self, **data):
     48        self.applyData(self.context, **data)
     49        self.redirect(self.url(self.context))
     50        return
     51
     52    @grok.action('Cancel')
     53    def cancel(self, **data):
     54        self.redirect(self.url(self.context))
     55        return
     56
     57class ManageFaculty(FormWrapMixin, grok.Viewlet):
     58    """A viewlet that renders the `ManageForm`.
     59    """
     60    grok.viewletmanager(MainArea)
     61    grok.context(IFaculty)
     62    grok.view(Manage)
     63    grok.require('waeup.manageUniversity')
     64   
     65    formview_name = 'manageform' # The name of the formview we want to
     66                                 # be rendered in this viewlet.
     67
     68class ManageLink(grok.Viewlet):
     69    grok.viewletmanager(LeftSidebar)
     70    grok.context(IFaculty)
     71    grok.view(Index)
     72    grok.order(5)
     73    # This link is only displayed, if the user is allowed to use it!
     74    grok.require('waeup.manageUniversity')
     75   
     76    def render(self):
     77        return u'<div class="portlet"><a href="manage">Settings</a></div>'
Note: See TracChangeset for help on using the changeset viewer.