Changeset 14719 for main/kofacustom.coewarri
- Timestamp:
- 12 Jul 2017, 11:20:16 (7 years ago)
- Location:
- main/kofacustom.coewarri/trunk/src/kofacustom/coewarri/students
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/kofacustom.coewarri/trunk/src/kofacustom/coewarri/students/browser.py
r14035 r14719 39 39 NigeriaExportPDFPaymentSlip, 40 40 NigeriaExportPDFClearanceSlip, 41 NigeriaExportPDFCourseRegistrationSlip 41 42 ) 42 43 … … 46 47 from kofacustom.coewarri.interfaces import MessageFactory as _ 47 48 49 class CustomExportPDFCourseRegistrationSlip( 50 NigeriaExportPDFCourseRegistrationSlip): 51 """Deliver a PDF slip of the context. 52 """ 53 grok.context(ICustomStudentStudyLevel) 54 55 def _signatures(self): 56 return ( 57 [('I, ' + self.context.student.display_fullname + 58 ', do hereby declare that the above information is ' 59 'true and correct. <br>', _('Student\'s Signature'), '<br>')], 60 [('', _('Course Adviser'), '<br>')], 61 [('', _('Head of Department'), '<br>')], 62 [('', _('Dean of School'))] 63 ) 64 65 def render(self): 66 portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE 67 Code = translate(_('Code'), 'waeup.kofa', target_language=portal_language) 68 Title = translate(_('Title'), 'waeup.kofa', target_language=portal_language) 69 Dept = translate(_('Dept.'), 'waeup.kofa', target_language=portal_language) 70 Faculty = translate(_('Faculty'), 'waeup.kofa', target_language=portal_language) 71 Cred = translate(_('Cred.'), 'waeup.kofa', target_language=portal_language) 72 #Mand = translate(_('Requ.'), 'waeup.kofa', target_language=portal_language) 73 Score = translate(_('Score'), 'waeup.kofa', target_language=portal_language) 74 Grade = translate(_('Grade'), 'waeup.kofa', target_language=portal_language) 75 studentview = StudentBasePDFFormPage(self.context.student, 76 self.request, self.omit_fields) 77 students_utils = getUtility(IStudentsUtils) 78 79 tabledata = [] 80 tableheader = [] 81 for i in range(1,7): 82 tabledata.append(sorted( 83 [value for value in self.context.values() if value.semester == i], 84 key=lambda value: str(value.semester) + value.code)) 85 tableheader.append([(Code,'code', 2.5), 86 (Title,'title', 5), 87 (Dept,'dcode', 1.5), (Faculty,'fcode', 1.5), 88 (Cred, 'credits', 1.5), 89 #(Mand, 'mandatory', 1.5), 90 (Score, 'score', 1.5), 91 (Grade, 'grade', 1.5), 92 #('Auto', 'automatic', 1.5) 93 ]) 94 return students_utils.renderPDF( 95 self, 'course_registration_slip.pdf', 96 self.context.student, studentview, 97 tableheader=tableheader, 98 tabledata=tabledata, 99 signatures=self._signatures(), 100 omit_fields=self.omit_fields 101 ) 102 -
main/kofacustom.coewarri/trunk/src/kofacustom/coewarri/students/tests/test_browser.py
r14658 r14719 30 30 from waeup.kofa.students.tests.test_browser import StudentsFullSetup 31 31 from waeup.kofa.students.accommodation import BedTicket 32 from waeup.kofa.browser.tests.test_pdf import samples_dir 32 33 from waeup.kofa.testing import FunctionalTestCase 33 34 from waeup.kofa.interfaces import ( … … 112 113 self.assertEqual(self.student['payments'].values()[3].p_level, 200) 113 114 return 115 116 def test_registration_pdf_slips(self): 117 # Student cant login if their password is not set 118 IWorkflowState(self.student).setState('school fee paid') 119 self.browser.open(self.login_path) 120 self.browser.getControl(name="form.login").value = self.student_id 121 self.browser.getControl(name="form.password").value = 'spwd' 122 self.browser.getControl("Login").click() 123 self.browser.getLink("Study Course").click() 124 self.browser.getLink("Add course list").click() 125 self.assertMatches('...Add current level 100 (Year 1)...', 126 self.browser.contents) 127 self.browser.getControl("Create course list now").click() 128 # A level with one course ticket was created 129 self.browser.getLink("100").click() 130 self.browser.getLink("Download course registration slip").click() 131 self.assertEqual(self.browser.headers['Status'], '200 Ok') 132 self.assertEqual(self.browser.headers['Content-Type'], 133 'application/pdf') 134 path = os.path.join(samples_dir(), 'course_registration_slip.pdf') 135 open(path, 'wb').write(self.browser.contents) 136 print "Sample PDF course_registration_slip.pdf written to %s" % path
Note: See TracChangeset for help on using the changeset viewer.