Changeset 4491 for waeup/branches/ulif-rewrite
- Timestamp:
- 31 Jul 2009, 07:19:54 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
waeup/branches/ulif-rewrite/src/waeup/university/department.py
r4466 r4491 5 5 from zope.component.interfaces import IFactory 6 6 from zope.interface import implementedBy 7 from waeup.interfaces import IDepartment 7 from waeup.interfaces import IDepartment, ICourse 8 8 from waeup.utils.helpers import getName 9 9 from waeup.widgets.interfaces import ITableProvider 10 from waeup.viewlets import MainArea, LeftSidebar, Index, FormWrapMixin, Manage 10 from waeup.viewlets import (MainArea, LeftSidebar, Index, FormWrapMixin, 11 Manage, AddCourse) 11 12 12 13 class Department(grok.Container): … … 129 130 def render(self): 130 131 return u'<div class="portlet"><a href="manage">Settings</a></div>' 132 133 class AddCourseForm(grok.AddForm): 134 grok.context(IDepartment) 135 form_fields = grok.AutoFields(ICourse) 136 label = 'Add a course' 137 138 @grok.action('Add course') 139 def addCourse(self, **data): 140 course = createObject(u'waeup.Course') 141 self.applyData(course, **data) 142 try: 143 self.context.courses.addCourse(course) 144 except DuplicationError: 145 self.status = Invalid('The name chosen already exists ' 146 'in the database') 147 return 148 self.redirect(self.url(self.context)) 149 150 class AddCourse(FormWrapMixin, grok.Viewlet): 151 """A viewlet that wraps the `AddFacultyForm`. 152 """ 153 grok.viewletmanager(MainArea) 154 grok.context(IDepartment) 155 grok.view(AddCourse) 156 grok.require('waeup.manageUniversity') 157 158 formview_name = 'addcourseform' # The name of the formview we 159 # want to be rendered in this 160 # viewlet.
Note: See TracChangeset for help on using the changeset viewer.