Ignore:
Timestamp:
25 Jul 2009, 11:06:38 (15 years ago)
Author:
uli
Message:

Build base for tables with codes and titles.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • waeup/branches/ulif-rewrite/src/waeup/tables.py

    r4431 r4432  
    22"""
    33import grok
    4 from waeup.interfaces import IUniversity, IFaculty, IDepartment
     4from waeup.interfaces import (IUniversity, IFacultyContainer, IFaculty,
     5                              IDepartment)
    56from waeup.widgets.interfaces import ITableProvider
    67from waeup.widgets.table import YUITable as Table
    78from waeup.widgets.table import Col
    89
    9 class DepartmentTableProvider(grok.Adapter):
    10     grok.context(IFaculty)
     10class CodeAndTitleTableProvider(grok.Adapter):
     11    grok.baseclass()
    1112    grok.provides(ITableProvider)
    1213
    13     title = 'Departments'
    14    
    15     def __init__(self, context):
    16         self.context = context
     14    title = None
    1715
    1816    def getTable(self, view=None):
    1917        data = self.context
     18        context_url = ''
     19        if view:
     20            context_url = view.url(self.context) + '/'
    2021        cols = (
    2122            Col(
    2223                header='Code', sortable=True,
    23                 data = tuple(['<a href="%s">%s</a>' % (
    24                             data[x].code, data[x].code) for x in data])),
     24                data = tuple(['<a href="%s%s">%s</a>' % (
     25                            context_url, data[x].code,
     26                            data[x].code) for x in data])),
    2527            Col(
    2628                header='Title', sortable=True,
     
    2931        self.table = Table(self.title, cols=cols)
    3032        return self.table
     33   
     34class DepartmentTableProvider(CodeAndTitleTableProvider):
     35    grok.context(IFaculty)
     36    grok.provides(ITableProvider)
     37    title = 'Departments'
     38
Note: See TracChangeset for help on using the changeset viewer.