- Timestamp:
- 28 Aug 2020, 08:36:00 (4 years ago)
- Location:
- main/kofacustom.iuokada/trunk/src/kofacustom/iuokada/applicants
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/kofacustom.iuokada/trunk/src/kofacustom/iuokada/applicants/browser.py
r16209 r16220 203 203 yield(dict(code=cert.code, title=title, selected=selected)) 204 204 205 def saveCourses(view , changed_fields=[]):205 def saveCourses(view): 206 206 """In custom packages we needed to customize the certificate 207 207 select widget. We just save course1 and course2 if these customized 208 208 fields appear in the form. 209 209 """ 210 changed_courses = [] 210 211 form = view.request.form 211 212 course1 = form.get('custom.course1', None) 213 if not course1: 214 return 'Please select your 1st Choice Course of Study.', None 215 cat = queryUtility(ICatalog, name='certificates_catalog') 216 results = list( 217 cat.searchResults(code=(course1, course1))) 218 new_course1 = results[0] 219 old_course1 = view.context.course1 220 if old_course1 != new_course1: 221 view.context.course1 = new_course1 222 changed_courses.append('course1') 223 new_course2 = None 224 old_course2 = view.context.course2 212 225 course2 = form.get('custom.course2', None) 213 cat = queryUtility(ICatalog, name='certificates_catalog')214 if course1:215 results = list(216 cat.searchResults(code=(course1, course1)))217 view.context.course1 = results[0]218 changed_fields.append('course1')219 226 if course2: 220 227 results = list( 221 228 cat.searchResults(code=(course2, course2))) 222 view.context.course2 = results[0] 223 changed_fields.append('course2') 224 return changed_fields 229 new_course2 = results[0] 230 if old_course2 != new_course2: 231 view.context.course2 = new_course2 232 changed_courses.append('course2') 233 return None, changed_courses 225 234 226 235 def display_fileupload(view, filename): … … 247 256 return getCerts(self, coursex) 248 257 249 def saveCourses(self , changed_fields):250 return saveCourses(self , changed_fields)258 def saveCourses(self): 259 return saveCourses(self) 251 260 252 261 def display_fileupload(self, filename): -
main/kofacustom.iuokada/trunk/src/kofacustom/iuokada/applicants/tests/test_browser.py
r16075 r16220 90 90 self.browser.getControl(name="form.middlename").value = 'Anthony' 91 91 self.browser.getControl(name="form.lastname").value = 'Tester' 92 self.browser.getControl(name="custom.course1").value = ['CERT1']93 92 self.browser.getControl(name="form.date_of_birth").value = '09/09/1988' 94 93 self.browser.getControl(name="form.sex").value = ['m'] … … 101 100 self.assertEqual(self.browser.headers['Status'], '200 Ok') 102 101 self.fill_correct_values() 102 self.browser.getControl(name="custom.course1").value = [''] 103 self.browser.getControl("Save").click() 104 self.assertTrue('Please select your 1st Choice Course of Study.' 105 in self.browser.contents) 106 self.browser.getControl(name="custom.course1").value = ['CERT1'] 103 107 self.browser.getControl("Save").click() 104 108 self.assertEqual(self.applicant.course1, self.certificate) … … 113 117 open(path, 'wb').write(self.browser.contents) 114 118 print "Sample application_slip.pdf written to %s" % path 115 # Log entries have been added 119 # Log entries have been added (course1 is missing because it was already stored) 116 120 logfile = os.path.join( 117 121 self.app['datacenter'].storage, 'logs', 'applicants.log') … … 120 124 'zope.mgr - kofacustom.iuokada.applicants.browser.CustomApplicantManageFormPage - ' 121 125 '%s - saved: firstname + middlename + lastname + date_of_birth ' 122 '+ sex + email + course1'126 '+ sex + email' 123 127 % (self.applicant.applicant_id) 124 128 in logcontent)
Note: See TracChangeset for help on using the changeset viewer.