Changeset 4450 for waeup/branches


Ignore:
Timestamp:
27 Jul 2009, 16:41:57 (15 years ago)
Author:
uli
Message:

Add a table provider for course containers.

File:
1 edited

Legend:

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

    r4442 r4450  
    33import grok
    44from waeup.interfaces import (IUniversity, IFacultyContainer, IFaculty,
    5                               IDepartment)
     5                              IDepartment, ICourseContainer)
    66from waeup.widgets.interfaces import ITableProvider
    77from waeup.widgets.table import YUITable as Table
     
    8989        self.table = Table(self.title, cols=cols)
    9090        return self.table
     91
     92class CourseContainerCourseTableProvider(CodeAndTitleTableProvider):
     93    grok.context(ICourseContainer)
     94    grok.provides(ITableProvider)
     95    title = 'Courses'
     96
     97    def getTable(self, view=None):
     98        data = self.data_source
     99        context_url = ''
     100        if view:
     101            context_url = view.url(self.context) + '/'
     102        cols = (
     103            Col(
     104                header='Code', sortable=True,
     105                data = tuple([self.getItemURL(view, data[x].code)
     106                              for x in data])),
     107            Col(
     108                header='Title', sortable=True,
     109                data = tuple([data[x].title for x in data])),
     110            )
     111        self.table = Table(self.title, cols=cols)
     112        return self.table
Note: See TracChangeset for help on using the changeset viewer.