Changeset 4236 for waeup/branches/ulif-rewrite/src
- Timestamp:
- 9 Jun 2009, 10:08:47 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
waeup/branches/ulif-rewrite/src/waeup/university/facultycontainer.py
r4233 r4236 1 import sys 1 2 import grok 2 3 from zope.component import getUtility … … 10 11 from waeup.interfaces import IFacultyContainer, IFaculty, IWAeUPCSVImporter 11 12 from waeup.utils.importexport import CSVImporter 12 from waeup.viewlets import MainArea, LeftSidebar, Index, Add, FormWrapMixin 13 from waeup.viewlets import (MainArea, LeftSidebar, Index, Add, Manage, 14 FormWrapMixin) 13 15 14 16 … … 102 104 return result 103 105 106 class ManageFacultyContainer(grok.Viewlet): 107 grok.viewletmanager(MainArea) 108 grok.context(IFacultyContainer) 109 grok.view(Manage) 110 grok.template('manage') 111 112 def update(self): 113 form = self.request.form 114 if 'CANCEL' in form.keys(): 115 self.view.redirect(self.view.url(self.context)) 116 if not 'DELETE' in form.keys(): 117 return 118 fac_id = form['fac_id'] 119 if not isinstance(fac_id, list): 120 fac_id = [fac_id] 121 deleted = [] 122 for id in fac_id: 123 try: 124 del self.context[id] 125 deleted.append(id) 126 except: 127 self.view.flash('Could not delete %s: %s: %s' % ( 128 id, sys.exc_info()[0], sys.exc_info()[1])) 129 if len(deleted): 130 self.view.flash('Successfully deleted: %s' % ', '.join(deleted)) 131 # We have to redirect to let flash messages appear immediately... 132 self.view.redirect(self.view.url()) 133 return 134 104 135 class AddFacultyForm(grok.AddForm): 105 136 grok.context(IFacultyContainer) … … 147 178 return u'<div class="portlet"><a href="add">Add faculty</a></div>' 148 179 149 180 class ManageFacultyLink(grok.Viewlet): 181 """A link in the left sidebar displaying 'Manage faculty' 182 """ 183 grok.viewletmanager(LeftSidebar) 184 grok.context(IFacultyContainer) 185 grok.view(Index) 186 grok.order(5) 187 grok.require('waeup.manageUniversity') 188 189 def render(self): 190 return u'<div class="portlet"><a href="manage">Manage faculties</a></div>'
Note: See TracChangeset for help on using the changeset viewer.