Changeset 4445


Ignore:
Timestamp:
27 Jul 2009, 16:16:47 (15 years ago)
Author:
uli
Message:

Add basic views (display, manage).

File:
1 edited

Legend:

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

    r4361 r4445  
    55from zope.component.interfaces import IFactory
    66from waeup.interfaces import ICourse
     7from waeup.viewlets import MainArea, Index, Manage, FormWrapMixin
    78
    89class Course(grok.Model):
     
    3738    def getInterfaces(self):
    3839        return implementedBy(Course)
     40
     41class DisplayForm(grok.DisplayForm):
     42    grok.context(ICourse)
     43    form_fields = grok.AutoFields(ICourse)
     44
     45   
     46class Content(FormWrapMixin, grok.Viewlet):
     47    """A viewlet that wraps the `AddDepartmentForm`.
     48    """
     49    grok.viewletmanager(MainArea)
     50    grok.context(ICourse)
     51    grok.view(Index)
     52    grok.require('waeup.manageUniversity')
     53
     54    formview_name = 'displayform' # The name of the formview we want
     55                                  # to be rendered in this viewlet.
     56
     57class ManageForm(grok.EditForm):
     58    """Manage the basic properties of a `Course` instance.
     59    """
     60
     61    form_fields = grok.AutoFields(ICourse)
     62
     63    @property
     64    def label(self):
     65        # Set department name as form label
     66        #return self.form_fields['title'].field.get(self.context)
     67        return ''
     68   
     69    @grok.action('Save')
     70    def save(self, **data):
     71        self.applyData(self.context, **data)
     72        return
     73   
     74    @grok.action('Save and return')
     75    def saveAndReturn(self, **data):
     76        self.applyData(self.context, **data)
     77        self.redirect(self.url(self.context))
     78        return
     79
     80    @grok.action('Cancel')
     81    def cancel(self, **data):
     82        self.redirect(self.url(self.context))
     83        return
     84
     85class ManageDepartment(FormWrapMixin, grok.Viewlet):
     86    """A viewlet that renders the `ManageForm`.
     87    """
     88    grok.viewletmanager(MainArea)
     89    grok.context(ICourse)
     90    grok.view(Manage)
     91    grok.require('waeup.manageUniversity')
     92   
     93    formview_name = 'manageform' # The name of the formview we want to
     94                                 # be rendered in this viewlet.
Note: See TracChangeset for help on using the changeset viewer.