Changeset 4499 for waeup/branches/ulif-rewrite/src
- Timestamp:
- 31 Jul 2009, 10:02:49 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
waeup/branches/ulif-rewrite/src/waeup/university/department.py
r4497 r4499 6 6 from zope.component.interfaces import IFactory 7 7 from zope.interface import implementedBy 8 from waeup.interfaces import IDepartment, ICourse 8 from waeup.interfaces import IDepartment, ICourse, ICertificate 9 9 from waeup.utils.helpers import getName 10 10 from waeup.widgets.interfaces import ITableProvider 11 11 from waeup.viewlets import (MainArea, LeftSidebar, Index, FormWrapMixin, 12 Manage, AddCourse )12 Manage, AddCourse, AddCertificate) 13 13 14 14 class Department(grok.Container): … … 175 175 # want to be rendered in this 176 176 # viewlet. 177 178 class AddCertificateForm(grok.AddForm): 179 grok.context(IDepartment) 180 # We need a deepcopy here, because otherwise also all other 181 # ICertificate forms would be affected. 182 form_fields = copy.deepcopy(grok.AutoFields(ICertificate)) 183 form_fields.get('code').field.readonly = False 184 label = 'Add a certificate' 185 186 @grok.action('Add certificate') 187 def addCertificate(self, **data): 188 certificate = createObject(u'waeup.Certificate') 189 self.applyData(certificate, **data) 190 try: 191 self.context.certificates.addCertificate(certificate) 192 except DuplicationError: 193 self.status = Invalid('The name chosen already exists ' 194 'in the database') 195 return 196 self.redirect(self.url(self.context)) 197 198 @grok.action('Cancel') 199 def cancel(self, **data): 200 self.redirect(self.url(self.context)) 201 return 202 203 204 class AddCertificate(FormWrapMixin, grok.Viewlet): 205 """A viewlet that wraps the `AddFacultyForm`. 206 """ 207 grok.viewletmanager(MainArea) 208 grok.context(IDepartment) 209 grok.view(AddCertificate) 210 grok.require('waeup.manageUniversity') 211 212 formview_name = 'addcertificateform' # The name of the formview we 213 # want to be rendered in this 214 # viewlet.
Note: See TracChangeset for help on using the changeset viewer.