Changeset 4503 for waeup/branches


Ignore:
Timestamp:
31 Jul 2009, 10:22:18 (15 years ago)
Author:
uli
Message:

Add manage viewlet/form for certificates.

File:
1 edited

Legend:

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

    r4502 r4503  
    99from waeup.interfaces import (ICertificate, ICertificateContainer,
    1010                              ICertificateCourse, ICourse, IDepartment)
    11 from waeup.viewlets import FormWrapMixin, Index, MainArea
     11from waeup.viewlets import FormWrapMixin, Index, Manage, MainArea
    1212
    1313class Certificate(grok.Container):
     
    118118                                  # to be rendered in this viewlet.
    119119
     120class ManageForm(grok.EditForm):
     121    """Manage the basic properties of a `Department` instance.
     122    """
     123    grok.context(ICertificate)
     124    form_fields = grok.AutoFields(ICertificate)
     125
     126    @property
     127    def label(self):
     128        # Set certificate name as form label
     129        return self.form_fields['title'].field.get(self.context)
     130   
     131    @grok.action('Save')
     132    def save(self, **data):
     133        self.applyData(self.context, **data)
     134        return
     135   
     136    @grok.action('Save and return')
     137    def saveAndReturn(self, **data):
     138        self.applyData(self.context, **data)
     139        self.redirect(self.url(self.context))
     140        return
     141
     142    @grok.action('Cancel')
     143    def cancel(self, **data):
     144        self.redirect(self.url(self.context))
     145        return
     146
     147class ManageCertificate(FormWrapMixin, grok.Viewlet):
     148    """A viewlet that renders the `ManageForm`.
     149    """
     150    grok.viewletmanager(MainArea)
     151    grok.context(ICertificate)
     152    grok.view(Manage)
     153    grok.require('waeup.manageUniversity')
     154   
     155    formview_name = 'manageform' # The name of the formview we want to
     156                                 # be rendered in this viewlet.
     157
    120158   
    121159@grok.subscribe(ICourse, grok.IObjectRemovedEvent)
Note: See TracChangeset for help on using the changeset viewer.