Changeset 12845 for main/waeup.uniben/trunk/src/waeup
- Timestamp:
- 2 Apr 2015, 10:51:44 (10 years ago)
- Location:
- main/waeup.uniben/trunk/src/waeup/uniben/students
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.uniben/trunk/src/waeup/uniben/students/browser.py
r12391 r12845 30 30 CourseTicketDisplayFormPage, StudentTriggerTransitionFormPage, 31 31 msave, emit_lock_message, 32 StudentActivatePage, StudentDeactivatePage) 32 StudentActivatePage, StudentDeactivatePage, 33 ExportPDFTranscriptPage) 34 from waeup.kofa.students.workflow import (CREATED, ADMITTED, PAID, 35 CLEARANCE, REQUESTED, RETURNING, CLEARED, REGISTERED, VALIDATED, 36 GRADUATED, TRANSCRIPT, FORBIDDEN_POSTGRAD_TRANS) 33 37 from waeup.kofa.students.interfaces import IStudentsUtils, ICourseTicket 34 38 from waeup.kofa.students.workflow import FORBIDDEN_POSTGRAD_TRANS … … 118 122 omit_fields = ('password', 'suspended', 'suspended_comment', 119 123 'phone', 'adm_code', 'email', 'date_of_birth') 124 125 def _signatures(self): 126 isStudent = getattr( 127 self.request.principal, 'user_type', None) == 'student' 128 if not isStudent and self.context.state in (CLEARED, RETURNING): 129 return ([_('Student Signature')], 130 [_('Clearance Officer Signature')]) 131 return 120 132 121 133 def render(self): … … 387 399 self.redirect(self.url(self.context)) 388 400 return 401 402 class CustomExportPDFTranscriptPage(ExportPDFTranscriptPage): 403 """Deliver a PDF slip of the context. 404 """ 405 406 def _sigsInFooter(self): 407 return [] 408 #return (_('CERTIFIED TRUE COPY'),) 409 410 def _signatures(self): 411 return ([( 412 'Current HD<br /> D. R. (Exams & Records)<br /> ' 413 'For: Registrar')],) 414 415 def render(self): 416 portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE 417 Term = translate(_('Term'), 'waeup.kofa', target_language=portal_language) 418 Code = translate(_('Code'), 'waeup.kofa', target_language=portal_language) 419 Title = translate(_('Title'), 'waeup.kofa', target_language=portal_language) 420 Cred = translate(_('Credits'), 'waeup.kofa', target_language=portal_language) 421 #Score = translate(_('Score'), 'waeup.kofa', target_language=portal_language) 422 Grade = translate(_('Grade'), 'waeup.kofa', target_language=portal_language) 423 studentview = StudentBasePDFFormPage(self.context.student, 424 self.request, self.omit_fields) 425 students_utils = getUtility(IStudentsUtils) 426 427 tableheader = [(Code,'code', 2.5), 428 (Title,'title', 8.5), 429 (Term, 'semester', 1.5), 430 (Cred, 'credits', 1.5), 431 #(Score, 'score', 1.5), 432 (Grade, 'grade', 1.5), 433 ] 434 435 return students_utils.renderPDFTranscript( 436 self, 'transcript.pdf', 437 self.context.student, studentview, 438 omit_fields=self.omit_fields, 439 tableheader=tableheader, 440 signatures=self._signatures(), 441 sigs_in_footer=self._sigsInFooter(), 442 ) -
main/waeup.uniben/trunk/src/waeup/uniben/students/student.py
r10488 r12845 39 39 def transcript_enabled(self): 40 40 user = get_current_principal() 41 if user.id in ('admin', 'isouaba', ' niyi', 'delejason'):41 if user.id in ('admin', 'isouaba', 'med', 'delejason', 'zope.mgr'): 42 42 return True 43 43 return False -
main/waeup.uniben/trunk/src/waeup/uniben/students/tests/test_browser.py
r12566 r12845 839 839 self.browser.open(self.student_path + '/clear') 840 840 self.assertTrue('Student has been cleared' in self.browser.contents) 841 842 def test_transcripts(self): 843 studylevel = createObject(u'waeup.StudentStudyLevel') 844 studylevel.level = 100 845 studylevel.level_session = 2005 846 self.student['studycourse'].entry_mode = 'ug_ft' 847 self.student['studycourse'].addStudentStudyLevel( 848 self.certificate, studylevel) 849 studylevel2 = createObject(u'waeup.StudentStudyLevel') 850 studylevel2.level = 110 851 studylevel2.level_session = 2006 852 self.student['studycourse'].addStudentStudyLevel( 853 self.certificate, studylevel2) 854 # Add second course (COURSE has been added automatically) 855 courseticket = createObject('waeup.CourseTicket') 856 courseticket.code = 'ANYCODE' 857 courseticket.title = u'Any TITLE' 858 courseticket.credits = 13 859 courseticket.score = 66 860 courseticket.semester = 1 861 courseticket.dcode = u'ANYDCODE' 862 courseticket.fcode = u'ANYFCODE' 863 self.student['studycourse']['110']['COURSE2'] = courseticket 864 self.student['studycourse']['100']['COURSE1'].score = 55 865 self.assertEqual(self.student['studycourse']['100'].gpa_params_rectified[0], 3.0) 866 self.assertEqual(self.student['studycourse']['110'].gpa_params_rectified[0], 4.0) 867 # Get transcript data 868 td = self.student['studycourse'].getTranscriptData() 869 self.assertEqual(td[0][0]['level_key'], '100') 870 self.assertEqual(td[0][0]['sgpa'], 3.0) 871 self.assertEqual(td[0][0]['level'].level, 100) 872 self.assertEqual(td[0][0]['level'].level_session, 2005) 873 self.assertEqual(td[0][0]['tickets_1'][0].code, 'COURSE1') 874 self.assertEqual(td[0][1]['level_key'], '110') 875 self.assertEqual(td[0][1]['sgpa'], 4.0) 876 self.assertEqual(td[0][1]['level'].level, 110) 877 self.assertEqual(td[0][1]['level'].level_session, 2006) 878 self.assertEqual(td[0][1]['tickets_1'][0].code, 'ANYCODE') 879 self.assertEqual(td[1], 3.57) 880 self.browser.addHeader('Authorization', 'Basic mgr:mgrpw') 881 self.browser.open(self.student_path + '/studycourse/transcript') 882 self.assertEqual(self.browser.headers['Status'], '200 Ok') 883 self.assertTrue('Transcript' in self.browser.contents) 884 # Officers can open the pdf transcript 885 self.browser.open(self.student_path + '/studycourse/transcript.pdf') 886 self.assertEqual(self.browser.headers['Status'], '200 Ok') 887 self.assertEqual(self.browser.headers['Content-Type'], 'application/pdf') 888 path = os.path.join(samples_dir(), 'transcript.pdf') 889 open(path, 'wb').write(self.browser.contents) 890 print "Sample PDF transcript.pdf written to %s" % path
Note: See TracChangeset for help on using the changeset viewer.