- Timestamp:
- 23 Feb 2012, 07:43:06 (13 years ago)
- Location:
- main/waeup.sirp/trunk/src/waeup/sirp/applicants
- Files:
-
- 1 deleted
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/applicants/browser.py
r7494 r7683 29 29 from waeup.sirp.applicants.interfaces import ( 30 30 IApplicant, IApplicantEdit, IApplicantsRoot, 31 IApplicantsContainer, IApplicantsContainerAdd, application_types_vocab,32 MAX_UPLOAD_SIZE, IApplicantOnlinePayment, 31 IApplicantsContainer, IApplicantsContainerAdd, 32 MAX_UPLOAD_SIZE, IApplicantOnlinePayment, IApplicantsUtils 33 33 ) 34 34 from waeup.sirp.applicants.workflow import INITIALIZED, STARTED, PAID, SUBMITTED … … 158 158 year = data['year'] 159 159 code = u'%s%s' % (data['prefix'], year) 160 prefix = application_types_vocab.getTerm(data['prefix']) 160 appcats_dict = getUtility(IApplicantsUtils).getApplicationTypeDict() 161 prefix = appcats_dict[data['prefix']][0] 161 162 title = u'%s %s/%s' % (prefix.title, year, year + 1) 162 163 if code in self.context.keys(): -
main/waeup.sirp/trunk/src/waeup/sirp/applicants/interfaces.py
r7682 r7683 23 23 from zope import schema 24 24 from zope.interface import Interface, Attribute, implements, directlyProvides 25 from zope.component import getUtilitiesFor, queryUtility 25 from zope.component import getUtilitiesFor, queryUtility, getUtility 26 26 from zope.catalog.interfaces import ICatalog 27 27 from zope.schema.interfaces import ( 28 28 ValidationError, ISource, IContextSourceBinder) 29 29 from zc.sourcefactory.basic import BasicSourceFactory 30 from zc.sourcefactory.contextual import BasicContextualSourceFactory 30 31 from waeup.sirp.schema import TextLineChoice 31 32 from waeup.sirp.interfaces import ( … … 35 36 from waeup.sirp.students.vocabularies import ( 36 37 lgas_vocab, CertificateSource, GenderSource) 37 from waeup.sirp.applicants.vocabularies import (38 application_types_vocab, AppCatCertificateSource)39 38 from waeup.sirp.payments.interfaces import IOnlinePayment 40 39 … … 78 77 directlyProvides(contextual_reg_num_source, IContextSourceBinder) 79 78 79 class AppCatCertificateSource(CertificateSource): 80 """An application certificate source delivers all courses which belong to 81 a certain application_category. 82 """ 83 def getValues(self, context): 84 # appliction category not available when certificate was deleted. 85 # shouldn't that info be part of applicant info instead? 86 # when we cannot determine the appcat, we will display all courses. 87 appcat = getattr(getattr(context, '__parent__', None), 88 'application_category', None) 89 catalog = getUtility(ICatalog, name='certificates_catalog') 90 result = catalog.searchResults( 91 application_category=(appcat,appcat)) 92 result = sorted(result, key=lambda value: value.code) 93 curr_course = context.course1 94 if curr_course is not None and curr_course not in result: 95 # display also current course even if it is not catalogued 96 # (any more) 97 result = [curr_course,] + result 98 return result 99 100 class ApplicationTypeSource(BasicContextualSourceFactory): 101 """An application type source delivers screening types defined in the 102 portal. 103 """ 104 def getValues(self, context): 105 self.appcats_dict = getUtility( 106 IApplicantsUtils).getApplicationTypeDict() 107 return sorted(self.appcats_dict.keys()) 108 109 def getToken(self, context, value): 110 return value 111 112 def getTitle(self, context, value): 113 return self.appcats_dict[value][0] 114 115 # Maybe Uniben still needs this ... 116 #class ApplicationPinSource(BasicContextualSourceFactory): 117 # """An application pin source delivers PIN prefixes for application 118 # defined in the portal. 119 # """ 120 # def getValues(self, context): 121 # self.apppins_dict = getUtility( 122 # IApplicantsUtils).getApplicationTypeDict() 123 # return sorted(self.appcats_dict.keys()) 124 # 125 # def getToken(self, context, value): 126 # return value 127 # 128 # def getTitle(self, context, value): 129 # return u"%s (%s)" % ( 130 # self.apppins_dict[value][1],self.apppins_dict[value][0]) 131 80 132 class ApplicantContainerProviderSource(BasicSourceFactory): 81 133 """A source offering all available applicants container types. … … 119 171 """A collection of methods which are subject to customization. 120 172 """ 173 pass 121 174 122 175 class IApplicantsRoot(ISIRPObject, IContainer): … … 151 204 152 205 prefix = schema.Choice( 153 title = u'Application target',154 required = True, 155 default = None, 156 source = application_types_vocab,206 title = u'Application Target', 207 required = True, 208 default = None, 209 source = ApplicationTypeSource(), 157 210 readonly = True, 158 211 ) … … 166 219 167 220 year = schema.Choice( 168 title = u'Year of entrance',221 title = u'Year of Entrance', 169 222 required = True, 170 223 default = None, … … 174 227 175 228 provider = schema.Choice( 176 title = u'Applicants container type',229 title = u'Applicants Container Type', 177 230 required = True, 178 231 default = None, … … 181 234 ) 182 235 236 # Maybe Uniben still needs this ... 183 237 #ac_prefix = schema.Choice( 184 238 # title = u'Activation code prefix', 185 239 # required = True, 186 240 # default = None, 187 # source = application_pins_vocab,241 # source = ApplicationPinSource(), 188 242 # ) 189 243 … … 203 257 204 258 startdate = schema.Date( 205 title = u'Application start date',259 title = u'Application Start Date', 206 260 required = False, 207 261 default = None, … … 209 263 210 264 enddate = schema.Date( 211 title = u'Application closing date',265 title = u'Application Closing Date', 212 266 required = False, 213 267 default = None, … … 254 308 """ 255 309 prefix = schema.Choice( 256 title = u'Application target',257 required = True, 258 default = None, 259 source = application_types_vocab,310 title = u'Application Target', 311 required = True, 312 default = None, 313 source = ApplicationTypeSource(), 260 314 readonly = False, 261 315 ) 262 316 263 317 year = schema.Choice( 264 title = u'Year of entrance',318 title = u'Year of Entrance', 265 319 required = True, 266 320 default = None, … … 270 324 271 325 provider = schema.Choice( 272 title = u'Applicants container type',326 title = u'Applicants Container Type', 273 327 required = True, 274 328 default = None, -
main/waeup.sirp/trunk/src/waeup/sirp/applicants/tests/test_interfaces.py
r7193 r7683 22 22 from zc.sourcefactory.browser.source import FactoredTerms 23 23 from zope.publisher.browser import TestRequest 24 from waeup.sirp.applicants. vocabularies import application_types_vocab24 from waeup.sirp.applicants.interfaces import ApplicationTypeSource 25 25 from waeup.sirp.students.vocabularies import GenderSource 26 27 class ApplicationCategoriesTestCase(unittest.TestCase):28 29 def setUp(self):30 self.vocab = application_types_vocab31 return32 33 def test_vocabulary_len(self):34 self.assertEqual(len(self.vocab), 10)35 return36 37 def test_vocabulary_items(self):38 self.assertTrue('pude' in self.vocab)39 return40 41 def test_term_attributes(self):42 # Check that each vocab entry provided value, token, and title.43 term = self.vocab.getTermByToken('pude')44 self.assertEqual(term.token, 'pude')45 self.assertEqual(term.value, 'pude')46 self.assertEqual(term.title, 'Post UDE Screening')47 return48 26 49 27 class InterfacesTest(unittest.TestCase): … … 82 60 suite = unittest.TestSuite() 83 61 for testcase in [ 84 ApplicationCategoriesTestCase,85 62 InterfacesTest, 86 63 ]:
Note: See TracChangeset for help on using the changeset viewer.