Changeset 10382 for main/waeup.imostate/trunk/src/waeup/imostate/applicants
- Timestamp:
- 25 Jun 2013, 12:46:38 (11 years ago)
- Location:
- main/waeup.imostate/trunk/src/waeup/imostate/applicants
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.imostate/trunk/src/waeup/imostate/applicants/browser.py
r10380 r10382 215 215 if not store.getFileByContext(self.context, attr=u'extraform.pdf'): 216 216 return _('No extra information form pdf file uploaded.') 217 if not store.getFileByContext(self.context, attr=u'refereeform.pdf'):218 return _('No referee form pdf file uploaded.')219 if self.target is not None and self.target.startswith('pg') \220 and not store.getFileByContext(self.context, attr=u'credentials.pdf'):221 return _('No credentials pdf file uploaded.')217 #if not store.getFileByContext(self.context, attr=u'refereeform.pdf'): 218 # return _('No referee form pdf file uploaded.') 219 #if self.target is not None and self.target.startswith('pg') \ 220 # and not store.getFileByContext(self.context, attr=u'credentials.pdf'): 221 # return _('No credentials pdf file uploaded.') 222 222 if not self.request.form.get('confirm_passport', False): 223 223 return _('Passport picture confirmation box not ticked.') -
main/waeup.imostate/trunk/src/waeup/imostate/applicants/browser_templates/applicanteditpage.pt
r10381 r10382 20 20 <a href="https://imostate.waeup.org/downloads/AttestationForm.pdf" 21 21 i18n:translate=""> 22 <strong>Attestation Form</strong></a> .23 Then scan the filled form together with other24 documents required for application:25 (1) Local Government Certificate of Ind egen,22 <strong>Attestation Form</strong></a>then, 23 upload a scanned copy of the filled attestation form. 24 Also, scan the following other documents required for application: 25 (1) Local Government Certificate of Indigene, 26 26 (2) Credentials and the 27 (3) NYSC Discharge Certificate. Print these four scanned documents 28 into a single pdf file and upload the file with the form below. 27 (3) NYSC Discharge Certificate. 28 Print these four scanned documents into a single pdf file and 29 upload the file as Extra Applicant Information Form below. 29 30 <br /><br /> 30 31 </p> … … 67 68 </p> 68 69 <input type="file" name="form.extraform" /> 69 <br />70 <span i18n:translate="">71 Max. file size:72 </span>73 <span tal:replace="view/max_file_upload_size">10 KB</span>74 </tr>75 <tr>76 <td class="fieldname" i18n:translate="">77 Referee's Form:78 </td>79 <td>80 <p tal:condition="python: view.file_exists('refereeform.pdf')">81 <a href="refereeform.pdf"82 i18n:translate="">83 Download pdf file84 </a>85 </p>86 <input type="file" name="form.refereeform" />87 <br />88 <span i18n:translate="">89 Max. file size:90 </span>91 <span tal:replace="view/max_file_upload_size">10 KB</span>92 </tr>93 <tr tal:condition="python: view.target.startswith('pg')">94 <td class="fieldname" i18n:translate="">95 Credentials:96 </td>97 <td>98 <p tal:condition="python: view.file_exists('credentials.pdf')">99 <a href="credentials.pdf"100 i18n:translate="">101 Download pdf file102 </a>103 </p>104 <input type="file" name="form.credentials" />105 70 <br /> 106 71 <span i18n:translate=""> -
main/waeup.imostate/trunk/src/waeup/imostate/applicants/interfaces.py
r10380 r10382 131 131 ) 132 132 133 ICustomUGApplicant[ 134 'locked'].order = IApplicantBaseData['suspended'].order 135 ICustomUGApplicant[ 136 'result_uploaded'].order = ICustomUGApplicant['suspended'].order 137 133 138 class ICustomApplicant(ICustomUGApplicant): 134 139 """An interface for both types of applicants. -
main/waeup.imostate/trunk/src/waeup/imostate/applicants/tests/test_browser.py
r10366 r10382 161 161 self.assertTrue(fd is None) 162 162 163 def test_upload_refereeform_by_student(self):164 self.login()165 self.browser.open(self.edit_path)166 # Create a pseudo file and select it to be uploaded in form167 pdf_content = 'A' * 1024 * 600 # A string of 600 KB size168 pseudo_file = StringIO(pdf_content)169 ctrl = self.browser.getControl(name='form.refereeform')170 file_ctrl = ctrl.mech_control171 file_ctrl.add_file(pseudo_file, filename='myform.pdf')172 self.browser.getControl("Save").click() # submit form173 # We get a warning message174 self.assertTrue(175 'Uploaded file is too big' in self.browser.contents)176 # Create a pseudo file with acceptable size177 pdf_content = 'A' * 1024 * 300 # A string of 300 KB size178 pseudo_file = StringIO(pdf_content)179 ctrl = self.browser.getControl(name='form.refereeform')180 file_ctrl = ctrl.mech_control181 file_ctrl.add_file(pseudo_file, filename='myform.pdf')182 self.browser.getControl("Save").click() # submit form183 # Even though the form could not be saved ...184 self.assertTrue('Required input is missing' in self.browser.contents)185 # ... the file has been successfully uploaded186 pdf_url = self.edit_path.replace('edit', 'refereeform.pdf')187 self.browser.open(pdf_url)188 self.assertEqual(189 self.browser.headers['content-type'], 'application/pdf')190 self.assertEqual(len(self.browser.contents), 307200)191 # There is really a file stored for the applicant192 storage = getUtility(IExtFileStore)193 file_id = IFileStoreNameChooser(self.applicant).chooseName(194 attr='refereeform.pdf')195 # The stored file can be fetched196 fd = storage.getFile(file_id)197 file_len = len(fd.read())198 self.assertEqual(file_len, 307200)199 # A file link is displayed on the edit view ...200 self.browser.open(self.edit_path)201 self.assertTrue('<a href="refereeform.pdf">' in self.browser.contents)202 # ... and on the dislay view203 self.browser.open(self.view_path)204 self.assertTrue('<a href="refereeform.pdf">Referee\'s Form</a>'205 in self.browser.contents)206 207 def test_upload_refereeform_by_manager(self):208 self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')209 self.browser.open(self.manage_path)210 # Create a pseudo file with acceptable size211 pdf_content = 'A' * 1024 * 300 # A string of 300 KB size212 pseudo_file = StringIO(pdf_content)213 ctrl = self.browser.getControl(name='form.refereeform')214 file_ctrl = ctrl.mech_control215 file_ctrl.add_file(pseudo_file, filename='myform.pdf')216 self.browser.getControl("Save").click() # submit form217 # Even though the form could not be saved ...218 self.assertTrue('Required input is missing' in self.browser.contents)219 # ... the file has been successfully uploaded220 pdf_url = self.manage_path.replace('manage', 'refereeform.pdf')221 self.browser.open(pdf_url)222 self.assertEqual(223 self.browser.headers['content-type'], 'application/pdf')224 self.assertEqual(len(self.browser.contents), 307200)225 # There is rally a file stored for the applicant226 storage = getUtility(IExtFileStore)227 file_id = IFileStoreNameChooser(self.applicant).chooseName(228 attr='refereeform.pdf')229 # The stored file can be fetched230 fd = storage.getFile(file_id)231 file_len = len(fd.read())232 self.assertEqual(file_len, 307200)233 # A file link is displayed on the edit view ...234 self.browser.open(self.manage_path)235 self.assertTrue('<a href="refereeform.pdf">' in self.browser.contents)236 # ... and on the dislay view237 self.browser.open(self.view_path)238 self.assertTrue('<a href="refereeform.pdf">Referee\'s Form</a>'239 in self.browser.contents)240 # Adding file is properly logged241 logfile = os.path.join(242 self.app['datacenter'].storage, 'logs', 'applicants.log')243 logcontent = open(logfile).read()244 self.assertTrue(245 'zope.mgr - waeup.imostate.applicants.browser.CustomApplicantManageFormPage'246 ' - %s - saved: refereeform'247 % (self.applicant.applicant_id)248 in logcontent)249 # When an applicant is removed, also the pdf files are gone.250 del self.app['applicants']['app2011'][self.applicant.application_number]251 fd = storage.getFile(file_id)252 self.assertTrue(fd is None)253 254 163 def test_applicant_workflow(self): 255 164 # Applicants can edit their record … … 275 184 file_ctrl = ctrl.mech_control 276 185 file_ctrl.add_file(pseudo_file, filename='myform.pdf') 277 ctrl = self.browser.getControl(name='form.refereeform')278 file_ctrl = ctrl.mech_control279 file_ctrl.add_file(pseudo_file, filename='myform.pdf')280 186 281 187 self.browser.getControl(name="confirm_passport").value = True
Note: See TracChangeset for help on using the changeset viewer.