- Timestamp:
- 26 Apr 2020, 09:22:35 (5 years ago)
- Location:
- main/kofacustom.iuokada/trunk/src/kofacustom/iuokada/applicants
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
main/kofacustom.iuokada/trunk/src/kofacustom/iuokada/applicants/browser.py
r16071 r16075 20 20 import grok 21 21 import os 22 from zope.component import getUtility 22 from zope.component import getUtility, queryUtility 23 from zope.catalog.interfaces import ICatalog 23 24 from zope.formlib.textwidgets import BytesDisplayWidget 24 25 from waeup.kofa.interfaces import ( … … 67 68 'special_application', 68 69 #'jamb_subjects_list', 69 'programme_type') 70 'programme_type', 71 'course1', 72 'course2',) 70 73 UG_OMIT_EDIT_FIELDS = UG_OMIT_MANAGE_FIELDS + OMIT_DISPLAY_FIELDS + ( 71 74 'student_id', … … 78 81 #'jamb_score', 79 82 #'jamb_reg_number', 80 'aggregate') 83 'aggregate', 84 ) 81 85 82 86 # PG has its own interface … … 106 110 'emp2_end', 107 111 'emp2_reason', 112 'course1', 113 'course2', 108 114 ) 109 115 PG_OMIT_EDIT_FIELDS = PG_OMIT_MANAGE_FIELDS + PG_OMIT_DISPLAY_FIELDS + ( … … 161 167 """ 162 168 163 @property164 def certs(self):169 def getCerts(self, coursex): 170 yield(dict(code='', title='--', selected='')) 165 171 appcatcertificatesource = AppCatCertificateSource().factory 166 for code in appcatcertificatesource.getValues(self.context): 167 title = appcatcertificatesource.getTitle(self.context, code) 168 yield(code, title) 172 for cert in appcatcertificatesource.getValues(self.context): 173 selected = '' 174 course = getattr(self.context, coursex) 175 if course is not None and course.code == cert.code: 176 selected = 'selected' 177 title = appcatcertificatesource.getTitle(self.context, cert) 178 yield(dict(code=cert.code, title=title, selected=selected)) 179 180 def saveCourses(self, changed_fields): 181 """In custom packages we needed to customize the certificate 182 select widget. We just save course1 and course2 if these customized 183 fields appear in the form. 184 """ 185 form = self.request.form 186 course1 = form.get('custom.course1', None) 187 course2 = form.get('custom.course2', None) 188 cat = queryUtility(ICatalog, name='certificates_catalog') 189 if course1: 190 results = list( 191 cat.searchResults(code=(course1, course1))) 192 self.context.course1 = results[0] 193 changed_fields.append('course1') 194 if course2: 195 results = list( 196 cat.searchResults(code=(course2, course2))) 197 self.context.course2 = results[0] 198 changed_fields.append('course2') 199 return changed_fields 169 200 170 201 @property … … 192 223 """ 193 224 194 @property195 def certs(self):225 def getCerts(self, coursex): 226 yield(dict(code='', title='--', selected='')) 196 227 appcatcertificatesource = AppCatCertificateSource().factory 197 for code in appcatcertificatesource.getValues(self.context): 198 title = appcatcertificatesource.getTitle(self.context, code) 199 yield(code, title) 228 for cert in appcatcertificatesource.getValues(self.context): 229 selected = '' 230 course = getattr(self.context, coursex) 231 if course is not None and course.code == cert.code: 232 selected = 'selected' 233 title = appcatcertificatesource.getTitle(self.context, cert) 234 yield(dict(code=cert.code, title=title, selected=selected)) 235 236 def saveCourses(self): 237 """In custom packages we needed to customize the certificate 238 select widget. We just save course1 and course2 if these customized 239 fields appear in the form. 240 """ 241 form = self.request.form 242 course1 = form.get('custom.course1', None) 243 course2 = form.get('custom.course2', None) 244 cat = queryUtility(ICatalog, name='certificates_catalog') 245 if course1: 246 results = list( 247 cat.searchResults(code=(course1, course1))) 248 self.context.course1 = results[0] 249 if course2: 250 results = list( 251 cat.searchResults(code=(course2, course2))) 252 self.context.course2 = results[0] 253 return 200 254 201 255 def display_fileupload(self, filename): … … 219 273 if not store.getFileByContext(self.context, attr=u'passport.jpg'): 220 274 return _('No passport picture uploaded.') 221 if not self.request.form.get('confirm_passport', False):222 return _('Passport picture confirmation box not ticked.')223 275 if self.context.subtype == 'transfer' and \ 224 276 not store.getFileByContext(self.context, attr=u'res_stat.pdf'): -
main/kofacustom.iuokada/trunk/src/kofacustom/iuokada/applicants/browser_templates/applicanteditpage.pt
r16070 r16075 24 24 25 25 <tr> 26 <td class="separator" colspan="2">For Demonstration Purposes Only!! <<<<</td> 26 <td class="separator" colspan="2"> 27 Programmes/Courses Desired 28 </td> 27 29 </tr> 28 30 <tr> 29 31 <td class="fieldname" i18n:translate=""> 30 Certificate:32 1st Choice Course of Study: 31 33 </td> 32 34 <td> 33 35 <input id="filterbox" class="kofa-filterbox form-control half" 34 placeholder="Enter search text, then select itembelow."36 placeholder="Enter search text, then select course below." 35 37 type="text" i18n:translate=""/> 36 38 <br /> 37 <select id="filteredselect" name="c ourse1"39 <select id="filteredselect" name="custom.course1" 38 40 class="form-control" size=5> 39 <span tal:repeat="item view/certs" 40 tal:omit-tag=""> 41 <option tal:attributes="value python:item[0]"> 42 <span tal:replace="python:item[1]">TITLE</span> 43 </option> 44 </span> 41 <option tal:repeat="item python:view.getCerts('course1')" 42 tal:attributes="value item/code; selected item/selected"> 43 <span tal:replace="item/title">TITLE</span> 44 </option> 45 45 </select> 46 46 </td> 47 47 </tr> 48 49 <tr> 50 <td class="separator" colspan="2">>>>></td> 48 <tr> 49 <td class="fieldname" i18n:translate=""> 50 2nd Choice Course of Study: 51 </td> 52 <td> 53 <input id="filterbox" class="kofa-filterbox form-control half" 54 placeholder="Enter search text, then select course below." 55 type="text" i18n:translate=""/> 56 <br /> 57 <select id="filteredselect" name="custom.course2" 58 class="form-control" size=5> 59 <option tal:repeat="item python:view.getCerts('course2')" 60 tal:attributes="value item/code; selected item/selected"> 61 <span tal:replace="item/title">TITLE</span> 62 </option> 63 </select> 64 </td> 65 </tr> 66 67 <tr> 68 <td class="separator" colspan="2"> 69 File Uploads 70 </td> 51 71 </tr> 52 72 … … 129 149 </table> 130 150 131 <div tal:condition="python: not view.manage_applications 132 and context.__parent__.with_picture"> 133 <input id="confirm_passport" name="confirm_passport" 134 type="checkbox" value="True"/> 135 <span i18n:translate=""> 136 I confirm that the Passport Photograph uploaded on this form is a 137 true picture of me. 138 </span> 139 </div> 151 <p style="color:red" 152 tal:condition="python: view.target in ('pg',) 153 and not view.manage_applications"> 140 154 <br /> 155 Note: Your admission will not be processed until at least 2 of your expected 156 3 referees have returned their assessment, while awaiting the 3rd referee, and 157 until your transcript has been sent to the address below:<br /><br /> 158 The Office of the Secretary<br /> 159 School of Post Graduate Studies & Research (Main Campus)<br /> 160 Igbinedion University, Okada<br /> 161 Edo State, Nigeria<br /><br /> 162 </p> 141 163 142 164 <div tal:condition="view/availableActions"> -
main/kofacustom.iuokada/trunk/src/kofacustom/iuokada/applicants/tests/test_browser.py
r15947 r16075 85 85 layer = FunctionalLayer 86 86 87 def test_application_slip(self): 87 def fill_correct_values(self): 88 # Fill the edit form with suitable values 89 self.browser.getControl(name="form.firstname").value = 'John' 90 self.browser.getControl(name="form.middlename").value = 'Anthony' 91 self.browser.getControl(name="form.lastname").value = 'Tester' 92 self.browser.getControl(name="custom.course1").value = ['CERT1'] 93 self.browser.getControl(name="form.date_of_birth").value = '09/09/1988' 94 self.browser.getControl(name="form.sex").value = ['m'] 95 self.browser.getControl(name="form.email").value = 'xx@yy.zz' 96 97 def test_manage_application(self): 88 98 self.browser.addHeader('Authorization', 'Basic mgr:mgrpw') 89 99 self.slip_path = self.view_path + '/application_slip.pdf' … … 92 102 self.fill_correct_values() 93 103 self.browser.getControl("Save").click() 104 self.assertEqual(self.applicant.course1, self.certificate) 105 self.assertEqual(self.applicant.course2, None) 94 106 IWorkflowState(self.applicant).setState('submitted') 95 107 self.browser.open(self.manage_path) … … 101 113 open(path, 'wb').write(self.browser.contents) 102 114 print "Sample application_slip.pdf written to %s" % path 115 # Log entries have been added 116 logfile = os.path.join( 117 self.app['datacenter'].storage, 'logs', 'applicants.log') 118 logcontent = open(logfile).read() 119 self.assertTrue( 120 'zope.mgr - kofacustom.iuokada.applicants.browser.CustomApplicantManageFormPage - ' 121 '%s - saved: firstname + middlename + lastname + date_of_birth ' 122 '+ sex + email + course1' 123 % (self.applicant.applicant_id) 124 in logcontent) 103 125 104 126 def test_upload_res_stat_by_manager(self):
Note: See TracChangeset for help on using the changeset viewer.