Changeset 4452
- Timestamp:
- 27 Jul 2009, 16:44:01 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
waeup/branches/ulif-rewrite/src/waeup/university/coursecontainer.py
r4363 r4452 5 5 from zope.component.interfaces import IFactory 6 6 from waeup.interfaces import ICourseContainer, ICourse 7 from waeup.viewlets import MainArea, Index, Manage, FormWrapMixin 8 from waeup.widgets.interfaces import ITableProvider 7 9 8 10 class CourseContainer(grok.Container): … … 36 38 def getInterfaces(self): 37 39 return implementedBy(CourseContainer) 40 41 class DisplayForm(grok.DisplayForm): 42 grok.context(ICourseContainer) 43 form_fields = grok.AutoFields(ICourseContainer) 44 45 46 class Content(FormWrapMixin, grok.Viewlet): 47 """A viewlet that wraps the `AddDepartmentForm`. 48 """ 49 grok.viewletmanager(MainArea) 50 grok.context(ICourseContainer) 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 57 class ManageForm(grok.EditForm): 58 """Manage the basic properties of a `Coursecontainer` instance. 59 """ 60 61 form_fields = grok.AutoFields(ICourseContainer) 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 85 class ManageCourseContainer(FormWrapMixin, grok.Viewlet): 86 """A viewlet that renders the `ManageForm`. 87 """ 88 grok.viewletmanager(MainArea) 89 grok.context(ICourseContainer) 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. 95 96 class CourseList(grok.Viewlet): 97 grok.viewletmanager(MainArea) 98 grok.context(ICourseContainer) 99 grok.view(Index) 100 grok.order(3) 101 102 def update(self): 103 self.table = ITableProvider(self.context).getTable(view=self.view) 104 self.table.need()
Note: See TracChangeset for help on using the changeset viewer.