Changeset 10695 for main/waeup.kwarapoly/trunk/src/waeup/kwarapoly
- Timestamp:
- 4 Nov 2013, 16:22:35 (11 years ago)
- Location:
- main/waeup.kwarapoly/trunk/src/waeup/kwarapoly/students
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kwarapoly/trunk/src/waeup/kwarapoly/students/browser.py
r10692 r10695 206 206 omit_fields=self.omit_fields 207 207 ) 208 209 class ExportPDFRegistrationSlipPage(grok.View): 210 """Deliver a PDF slip of the context. 211 """ 212 grok.context(ICustomStudent) 213 grok.name('registration_form.pdf') 214 grok.require('waeup.viewStudent') 215 prefix = 'form' 216 omit_fields = ( 217 'suspended', 'phone', 218 'adm_code', 'suspended_comment', 'email', 'sex', 219 'current_mode', 'matric_number') 220 title = '' 221 label = 'Registration Form' 222 223 form_fields = grok.AutoFields(ICustomStudent).select( 224 'marit_stat', 'lga', 'nationality', 225 'perm_address',) 226 227 def render(self): 228 studentview = StudentBasePDFFormPage(self.context.student, 229 self.request, self.omit_fields) 230 students_utils = getUtility(IStudentsUtils) 231 return students_utils.renderPDF( 232 self, 'registration_form.pdf', 233 self.context.student, studentview, signatures=([_('Bursar')],), 234 omit_fields=self.omit_fields) -
main/waeup.kwarapoly/trunk/src/waeup/kwarapoly/students/tests/test_browser.py
r10692 r10695 348 348 return 349 349 350 def test_ pdf_slips(self):350 def test_admission_pdf_slips(self): 351 351 # Login 352 352 self.browser.open(self.login_path) … … 367 367 self.assertRaises( 368 368 LinkNotFoundError, self.browser.getLink, 'Download admission notification') 369 self.browser.open(self.student_path , 'admission_notification.pdf')370 self.assert False('Not allowed' in self.browser.contents)369 self.browser.open(self.student_path + '/admission_notification.pdf') 370 self.assertTrue('Not allowed' in self.browser.contents) 371 371 # admission notification 372 372 IWorkflowState(self.student).setState('cleared') … … 382 382 self.assertRaises( 383 383 LinkNotFoundError, self.browser.getLink, 'Download admission letter') 384 self.browser.open(self.student_path , 'admission_slip.pdf')385 self.assert False('Not allowed' in self.browser.contents)386 return 387 388 def test_ course_registration_pdf_slip(self):384 self.browser.open(self.student_path + '/admission_slip.pdf') 385 self.assertTrue('Not allowed' in self.browser.contents) 386 return 387 388 def test_registration_pdf_slips(self): 389 389 # Student cant login if their password is not set 390 390 IWorkflowState(self.student).setState('school fee paid') … … 407 407 open(path, 'wb').write(self.browser.contents) 408 408 print "Sample PDF course_registration_slip.pdf written to %s" % path 409 return 409 410 self.browser.open(self.student_path) 411 self.browser.getLink("Download registration form").click() 412 self.assertEqual(self.browser.headers['Status'], '200 Ok') 413 self.assertEqual(self.browser.headers['Content-Type'], 414 'application/pdf') 415 path = os.path.join(samples_dir(), 'registration_form.pdf') 416 open(path, 'wb').write(self.browser.contents) 417 print "Sample PDF registration_form.pdf written to %s" % path 418 419 return -
main/waeup.kwarapoly/trunk/src/waeup/kwarapoly/students/viewlets.py
r10691 r10695 70 70 return '' 71 71 return self.view.url(self.view.context, self.target) 72 73 class RegistrationFormActionButton(ManageActionButton): 74 grok.order(4) 75 grok.context(IStudent) 76 grok.view(StudentBaseDisplayFormPage) 77 grok.require('waeup.viewStudent') 78 icon = 'actionicon_pdf.png' 79 text = _('Download registration form') 80 target = 'registration_form.pdf' 81 82 @property 83 def target_url(self): 84 if self.context.state in (CREATED,): 85 return '' 86 return self.view.url(self.view.context, self.target)
Note: See TracChangeset for help on using the changeset viewer.