- Timestamp:
- 30 May 2011, 11:38:19 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/applicants/interfaces.py
r6205 r6248 27 27 from grokcore.content.interfaces import IContainer 28 28 from zc.sourcefactory.basic import BasicSourceFactory 29 from zc.sourcefactory.contextual import BasicContextualSourceFactory 29 30 from zope import schema 30 31 from zope.component import getUtility, getUtilitiesFor 31 32 from zope.interface import Interface, Attribute 33 from zope.catalog.interfaces import ICatalog 32 34 from zope.pluggableauth.interfaces import IPrincipalInfo 33 35 from zope.security.interfaces import IGroupClosureAwarePrincipal as IPrincipal … … 72 74 *[(u"%s (%s)" % (x[2],x[0]),x[2]) for x in APPLICATION_TYPES]) 73 75 76 class CertificateSource(BasicContextualSourceFactory): 77 """A certificate source delivers all certificates provided 78 in the portal. 79 """ 80 def getValues(self, context): 81 catalog = getUtility(ICatalog, name='certificates_catalog') 82 return sorted(list( 83 catalog.searchResults( 84 code=('', 'z*'))), 85 key=lambda value: value.code) 86 87 def getToken(self, context, value): 88 return value.code 89 90 def getTitle(self, context, value): 91 return "%s - %s" % (value.code, value.title[:64]) 92 93 class AppCatCertificateSource(CertificateSource): 94 """An application certificate source delivers all courses which belong to 95 a certain application_category. 96 """ 97 def getValues(self, context): 98 appcat = context.__parent__.application_category 99 catalog = getUtility(ICatalog, name='certificates_catalog') 100 return sorted(list( 101 catalog.searchResults( 102 code=('', 'z*'), 103 application_category=(appcat,appcat))), 104 key=lambda value: value.code) 105 74 106 def year_range(): 75 107 curr_year = datetime.now().year … … 325 357 readonly = True, 326 358 ) 327 course1 = schema.TextLine( 328 # XXX: should be choice 359 course1 = schema.Choice( 329 360 title = u'1st Choice Course of Study', 330 required = False,331 )332 course2 = schema.TextLine(333 # XXX: should be choice361 source = AppCatCertificateSource(), 362 required = False, 363 ) 364 course2 = schema.Choice( 334 365 title = u'2nd Choice Course of Study', 366 source = AppCatCertificateSource(), 335 367 required = False, 336 368 ) … … 403 435 required = False, 404 436 ) 405 course_admitted = schema. TextLine(437 course_admitted = schema.Choice( 406 438 # XXX: should be choice 407 439 title = u'Admitted Course of Study', 440 source = CertificateSource(), 408 441 required = False, 409 442 ) … … 422 455 readonly = True, 423 456 ) 424 425 457 426 458 class IApplicant(IApplicantBaseData):
Note: See TracChangeset for help on using the changeset viewer.