Changeset 4559


Ignore:
Timestamp:
16 Dec 2009, 10:37:20 (15 years ago)
Author:
uli
Message:

Add a source for courses and update ICertificateCourse to use this
source.

File:
1 edited

Legend:

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

    r4512 r4559  
    11##
    22## interfaces.py
     3from zc.sourcefactory.basic import BasicSourceFactory
     4from zope.component import getUtility
     5from zope.app.catalog.interfaces import ICatalog
    36from zope.interface import Interface, Attribute
    47from zope import schema
     
    1215    return SimpleVocabulary([
    1316            SimpleTerm(value, value, title) for title, value in terms])
     17
     18
     19class CourseSource(BasicSourceFactory):
     20    """A course source delivers all courses inside the portal by looking
     21       up a catalog.
     22    """
     23    catalog = None
     24    def getValues(self):
     25        if self.catalog is None:
     26            self.catalog = getUtility(ICatalog, name='courses_catalog')
     27        result = list(self.catalog.searchResults(code=('', 'z*')))
     28       
     29    def getTitle(self, value):
     30        return "%s %s" % (value.code, value.title[:32])
     31
    1432
    1533class IWAeUPObject(Interface):
     
    228246   
    229247
     248   
    230249class ICertificateContainer(IWAeUPContainer):
    231250    """A container for certificates.
     
    238257
    239258class ICertificateCourse(IWAeUPObject):
    240     """A course as part of a certificate.
    241     """
    242     course = Attribute("A course instance.")
    243 
     259    """A certificatecourse is a course referenced by a certificate, which
     260       provides some own attributes.
     261    """
     262    course = schema.Choice(
     263        title = u'Course',
     264        source = CourseSource(),
     265        )
     266   
    244267    level = schema.Int(
    245268        title = u'Level of this course',
Note: See TracChangeset for help on using the changeset viewer.