Changeset 6913


Ignore:
Timestamp:
19 Oct 2011, 17:17:23 (13 years ago)
Author:
Henrik Bettermann
Message:

Extend certificates_catalog and let's search for certificates too.

File:
1 edited

Legend:

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

    r6839 r6913  
    3535    code = grok.index.Field(attribute='code')
    3636    application_category = grok.index.Field(attribute='application_category')
     37    title = grok.index.Text(attribute='title')
    3738
    3839class CertificateCoursesIndexes(grok.Indexes):
     
    118119        self.type = 'Course'
    119120
     121class CertificatesQueryResultItem(object):
     122    grok.implements(IQueryResultItem)
     123
     124    def __init__(self, context, view):
     125        self.context = context
     126        self.url = view.url(context)
     127        self.title = context.title
     128        self.code = context.code
     129        self.type = 'Certificate'
     130
    120131class CertificateCoursesQueryResultItem(object):
    121132    grok.implements(IQueryResultItem)
     
    143154        for result in results:
    144155            hitlist.append(CoursesQueryResultItem(result, view=view))
    145 
     156        results = Query().searchResults(
     157            Eq(('certificates_catalog', 'code'), query))
     158        for result in results:
     159            hitlist.append(CertificatesQueryResultItem(result, view=view))
     160        results = Query().searchResults(
     161            Text(('certificates_catalog', 'title'), query))
     162        for result in results:
     163            hitlist.append(CertificatesQueryResultItem(result, view=view))
    146164        results = Query().searchResults(
    147165            Eq(('certcourses_catalog', 'course_code'), query))
Note: See TracChangeset for help on using the changeset viewer.