Changeset 4686
- Timestamp:
- 6 Jan 2010, 02:21:39 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
waeup/branches/ulif-layout/src/waeup/hostel/hostelcontainer.py
r4081 r4686 3 3 from zope.interface import implementedBy 4 4 from waeup.interfaces import IHostelContainer, IHostel 5 from waeup.viewlets import MainArea, Index, Add, FormWrapMixin6 5 7 6 class HostelContainer(grok.Container): … … 36 35 def getInterfaces(self): 37 36 return implementedBy(HostelContainer) 38 39 40 class AddHostelForm(grok.AddForm):41 grok.context(IHostelContainer)42 form_fields = grok.AutoFields(IHostel)43 label = 'Add a hostel'44 45 @grok.action('Add hostel')46 def addHostel(self, **data):47 hostel = getUtility(IHostel)48 self.applyData(hostel, **data)49 try:50 self.context.addHostel(hostel)51 except DuplicationError:52 self.status = Invalid('The name chosen already exists '53 'in the database')54 return55 self.redirect(self.url(self.context))56 57 class AddHostel(FormWrapMixin, grok.Viewlet):58 """A viewlet that wraps the `AddHostelForm`.59 """60 grok.viewletmanager(MainArea)61 grok.context(IHostelContainer)62 grok.view(Add)63 grok.require('waeup.manageUniversity')64 65 formview_name = 'addhostelform' # The name of the formview we want66 # to be rendered in this viewlet.67
Note: See TracChangeset for help on using the changeset viewer.