Ignore:
Timestamp:
28 May 2011, 07:32:01 (13 years ago)
Author:
Henrik Bettermann
Message:

Add certificates catalog.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.sirp/trunk/src/waeup/sirp/university/catalog.py

    r6207 r6208  
    1111from waeup.sirp.university.interfaces import (
    1212    ICourse, ICertificateCourse, IDepartment,
     13    ICertificate,
    1314    )
    1415
    1516class CourseIndexes(grok.Indexes):
     17    """This catalog is needed for building sources.
     18    """
    1619    grok.site(IUniversity)
    1720    grok.name('courses_catalog')
     
    2124    title = grok.index.Text(attribute='title')
    2225
    23 class CourseCertificatesIndexes(grok.Indexes):
     26class CertificatesIndexes(grok.Indexes):
     27    """This catalog is needed for building sources.
     28    """
     29    grok.site(IUniversity)
     30    grok.name('certifcates_catalog')
     31    grok.context(ICertificate)
     32
     33    code = grok.index.Field(attribute='code')
     34    title = grok.index.Field(attribute='application_category')
     35
     36class CertificateCoursesIndexes(grok.Indexes):
     37    """This catalog is needed for automatic removal of certificate courses
     38    and later for selection course tickets in the students section.
     39    """
    2440    grok.site(IUniversity)
    2541    grok.name('certcourses_catalog')
     
    4763        # catalog not available. This might happen during tests.
    4864        return
     65    intids = getUtility(IIntIds)
     66    index = cat['code']
     67    index.index_doc(intids.getId(obj), obj)
     68
     69@grok.subscribe(ICourse, grok.IObjectAddedEvent)
     70def handleCertificateAdd(obj, event):
     71    """Index an added certificates with the local catalog.
     72
     73    See handleCourseAdd.
     74    """
     75    try:
     76      cat = getUtility(ICatalog, name='certificates_catalog')
     77    except ComponentLookupError:
     78      # catalog not available. This might happen during tests.
     79      return
    4980    intids = getUtility(IIntIds)
    5081    index = cat['code']
Note: See TracChangeset for help on using the changeset viewer.