Changeset 4738
- Timestamp:
- 8 Jan 2010, 03:39:34 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
waeup/branches/ulif-layout/src/waeup/university/coursecontainer.py
r4470 r4738 5 5 from zope.component.interfaces import IFactory 6 6 from waeup.interfaces import ICourseContainer, ICourse 7 from waeup.viewlets import MainArea, Index, Manage, FormWrapMixin8 from waeup.widgets.interfaces import ITableProvider9 7 10 8 class CourseContainer(grok.Container): … … 15 13 16 14 def addCourse(self, course): 15 """Add a course. 16 """ 17 17 if not ICourse.providedBy(course): 18 18 raise TypeError('CourseContainers contain only ICourse instances') … … 21 21 22 22 def clear(self): 23 """Remove all objects from course container. 24 """ 23 25 keys = self.keys() 24 26 for key in keys: … … 38 40 def getInterfaces(self): 39 41 return implementedBy(CourseContainer) 40 41 42 class ManageForm(grok.EditForm):43 """Manage the basic properties of a `Coursecontainer` instance.44 """45 46 form_fields = grok.AutoFields(ICourseContainer)47 48 @property49 def label(self):50 # Set department name as form label51 #return self.form_fields['title'].field.get(self.context)52 return ''53 54 @grok.action('Save')55 def save(self, **data):56 self.applyData(self.context, **data)57 return58 59 @grok.action('Save and return')60 def saveAndReturn(self, **data):61 self.applyData(self.context, **data)62 self.redirect(self.url(self.context))63 return64 65 @grok.action('Cancel')66 def cancel(self, **data):67 self.redirect(self.url(self.context))68 return69 70 class ManageCourseContainer(FormWrapMixin, grok.Viewlet):71 """A viewlet that renders the `ManageForm`.72 """73 grok.viewletmanager(MainArea)74 grok.context(ICourseContainer)75 grok.view(Manage)76 grok.require('waeup.manageUniversity')77 78 formview_name = 'manageform' # The name of the formview we want to79 # be rendered in this viewlet.80 81 class CourseList(grok.Viewlet):82 grok.viewletmanager(MainArea)83 grok.context(ICourseContainer)84 grok.view(Index)85 grok.order(3)86 87 def update(self):88 self.table = ITableProvider(self.context).getTables(view=self.view)[0]89 self.table.need()
Note: See TracChangeset for help on using the changeset viewer.