Changeset 4434 for waeup/branches
- Timestamp:
- 25 Jul 2009, 11:31:00 (15 years ago)
- Location:
- waeup/branches/ulif-rewrite/src/waeup
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
waeup/branches/ulif-rewrite/src/waeup/app.py
r4409 r4434 13 13 from waeup.users import UserContainer 14 14 from waeup.widgets.interfaces import ITableProvider 15 from waeup.widgets.table import Table, Col, YUITable16 15 17 16 class University(grok.Application, grok.Container): … … 95 94 # be rendered in this viewlet. 96 95 97 class FacultyTableProvider(grok.Adapter):98 grok.context(IUniversity)99 grok.provides(ITableProvider)100 101 def __init__(self, context):102 self.context = context103 data = self.context.faculties104 cols = (105 Col(106 header='Code', sortable=True,107 data = tuple(['<a href="faculties/%s">%s</a>' % (108 data[x].code, data[x].code) for x in data])),109 Col(110 header='Prefix', sortable=True,111 data = tuple([data[x].title_prefix for x in data])),112 Col(113 header='Title', sortable=True,114 data = tuple([data[x].title for x in data])),115 )116 self.table = YUITable('Faculties', cols=cols)117 118 def getTable(self):119 return self.table120 121 96 class Content(grok.Viewlet): 122 97 grok.viewletmanager(MainArea) … … 125 100 126 101 def update(self): 127 self.table = ITableProvider(self.context).getTable( )102 self.table = ITableProvider(self.context).getTable(self.view) 128 103 self.table.need() 129 104 -
waeup/branches/ulif-rewrite/src/waeup/tables.py
r4433 r4434 9 9 10 10 class CodeAndTitleTableProvider(grok.Adapter): 11 """A table provider for objects that have a code, title and prefix. 12 """ 11 13 grok.baseclass() 12 14 grok.provides(ITableProvider) … … 14 16 title = None 15 17 18 def __init__(self, context): 19 self.context = context 20 self.prepare() 21 22 def prepare(self): 23 self.data_source = self.context 24 25 def getItemURL(self, view, value): 26 context_url = '' 27 if not view is None: 28 context_url = view.url(self.data_source) + '/' 29 result = '<a href="%s%s">%s</a>' % (context_url, value, value) 30 return result 31 16 32 def getTable(self, view=None): 17 data = self. context33 data = self.data_source 18 34 context_url = '' 19 35 if view: … … 22 38 Col( 23 39 header='Code', sortable=True, 24 data = tuple(['<a href="%s%s">%s</a>' % ( 25 context_url, data[x].code, 26 data[x].code) for x in data])), 40 data = tuple([self.getItemURL(view, data[x].code) 41 for x in data])), 27 42 Col( 28 43 header='Title', sortable=True, … … 41 56 grok.provides(ITableProvider) 42 57 title = 'Faculties' 58 59 class UniversityTableProvider(CodeAndTitleTableProvider): 60 grok.context(IUniversity) 61 grok.provides(ITableProvider) 62 title = 'Faculties' 63 64 def prepare(self): 65 self.data_source = self.context.faculties
Note: See TracChangeset for help on using the changeset viewer.