- Timestamp:
- 21 Jul 2009, 14:59:33 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
waeup/branches/ulif-rewrite/src/waeup/university/facultycontainer.py
r4390 r4412 10 10 from waeup.viewlets import (MainArea, LeftSidebar, Index, Add, Manage, 11 11 FormWrapMixin) 12 12 from waeup.widgets.interfaces import ITableProvider 13 from waeup.widgets.table import Col, YUITable 13 14 14 15 class FacultyContainer(grok.Container): … … 29 30 del self[key] 30 31 32 def getName(self, key): 33 if key in self.keys(): 34 fac = self[key] 35 prefix = fac.title_prefix 36 prefix = prefix[0].upper() + prefix[1:] 37 return '%s of %s' % (prefix, fac.title) 38 31 39 class FacultyContainerFactory(grok.GlobalUtility): 32 40 """A factory for faculty containers. … … 52 60 grok.view(Index) 53 61 62 def update(self): 63 self.table = ITableProvider(self.context).getTable() 64 self.table.need() 65 54 66 def getFaculties(self): 55 67 """Convinience method to create a sorted list of faculties. … … 148 160 def render(self): 149 161 return u'<div class="portlet"><a href="manage">Manage faculties</a></div>' 162 163 class FacultyTableProvider(grok.Adapter): 164 grok.context(IFacultyContainer) 165 grok.provides(ITableProvider) 166 167 def __init__(self, context): 168 self.context = context 169 data = self.context 170 cols = ( 171 Col( 172 header='Code', sortable=True, 173 data = tuple(['<a href="%s">%s</a>' % ( 174 data[x].code, data[x].code) for x in data])), 175 Col( 176 header='Title', sortable=True, 177 data = tuple([data.getName(x) for x in data])), 178 ) 179 self.table = YUITable('Faculties', cols=cols) 180 181 def getTable(self): 182 return self.table
Note: See TracChangeset for help on using the changeset viewer.