Changeset 4429
- Timestamp:
- 25 Jul 2009, 08:41:07 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
waeup/branches/ulif-rewrite/src/waeup/university/faculty.py
r4427 r4429 7 7 from waeup.viewlets import (MainArea, LeftSidebar, Index, FormWrapMixin, 8 8 Manage, Add) 9 from waeup.widgets.interfaces import ITableProvider 10 from waeup.widgets.table import YUITable, Col 9 11 10 12 class Faculty(grok.Container): … … 29 31 for key in keys: 30 32 del self[key] 33 34 def getName(self, key): 35 if key in self.keys(): 36 dept = self[key] 37 prefix = dept.title_prefix 38 prefix = prefix[0].upper() + prefix[1:] 39 return '%s of %s' % (prefix, dept.title) 31 40 32 41 … … 65 74 grok.order(3) 66 75 76 def update(self): 77 self.table = ITableProvider(self.context).getTable() 78 self.table.need() 67 79 68 80 class ManageForm(grok.EditForm): … … 159 171 return u'<div class="portlet"><a href="add">Add department</a></div>' 160 172 173 class DepartmentTableProvider(grok.Adapter): 174 grok.context(IFaculty) 175 grok.provides(ITableProvider) 161 176 177 def __init__(self, context): 178 self.context = context 179 data = self.context 180 cols = ( 181 Col( 182 header='Code', sortable=True, 183 data = tuple(['<a href="%s">%s</a>' % ( 184 data[x].code, data[x].code) for x in data])), 185 Col( 186 header='Title', sortable=True, 187 data = tuple([data.getName(x) for x in data])), 188 ) 189 self.table = YUITable('Departments', cols=cols) 190 191 def getTable(self): 192 return self.table 193
Note: See TracChangeset for help on using the changeset viewer.