Changeset 17917 for main/waeup.kofa/trunk/src/waeup/kofa
- Timestamp:
- 7 Sep 2024, 15:38:05 (2 months ago)
- Location:
- main/waeup.kofa/trunk/src/waeup/kofa/students
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/students/browser.py
r17914 r17917 3016 3016 return 3017 3017 3018 class ExportPDFFinalClearanceSlip(UtilityView, grok.View): 3019 """Deliver a PDF document. 3020 """ 3021 grok.context(IStudent) 3022 grok.name('final_clearance_slip.pdf') 3023 grok.require('waeup.viewStudent') 3024 prefix = 'form' 3025 form_fields = None 3026 3027 omit_fields = ( 3028 'suspended', 3029 'adm_code', 3030 'suspended_comment', 3031 'current_level', 3032 'flash_notice', 3033 'entry_session', 3034 'parents_email', 3035 'email', 3036 'phone', 3037 'date_of_birth', 3038 'sex',) 3039 3040 @property 3041 def label(self): 3042 portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE 3043 return translate(_('Final Clearance Document'), 'waeup.kofa', 3044 target_language=portal_language) 3045 3046 def render(self): 3047 final_slip = getUtility(IExtFileStore).getFileByContext( 3048 self.context.student, attr='routingslip.pdf') 3049 if not final_slip: 3050 emit_lock_message(self, 3051 _('The requested form is locked.')) 3052 return 3053 studentview = StudentBasePDFFormPage(self.context.student, 3054 self.request, self.omit_fields) 3055 students_utils = getUtility(IStudentsUtils) 3056 note = _(''' 3057 The final clearance routing slip has been successfully uploaded onto the Kofa portal. 3058 3059 Take this slip to the Exams and Records Division for the collection of Statement of Results. 3060 ''') 3061 portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE 3062 note = translate( 3063 note, 'waeup.kofa', target_language=portal_language) 3064 return students_utils.renderPDF( 3065 self, 'final_clearance_slip.pdf', 3066 self.context.student, studentview, 3067 omit_fields=self.omit_fields, 3068 note=note) 3069 3018 3070 class StartClearancePage(KofaPage): 3019 3071 grok.context(IStudent) -
main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py
r17898 r17917 3058 3058 print "Sample png file written to %s" % path 3059 3059 3060 def test_student_final_clearance(self): 3061 self.student.browsertest = True 3062 self.browser.open(self.login_path) 3063 self.browser.getControl(name="form.login").value = self.student_id 3064 self.browser.getControl(name="form.password").value = 'spwd' 3065 self.browser.getControl("Login").click() 3066 self.browser.open(self.student_path) 3067 self.browser.getLink("Upload final clearance routing slip").click() 3068 ctrl = self.browser.getControl(name='finalclearanceuploadedit') 3069 file_obj = open(SAMPLE_PDF, 'rb') 3070 file_ctrl = ctrl.mech_control 3071 file_ctrl.add_file(file_obj, filename='routing_slip.pdf') 3072 self.browser.getControl( 3073 name='upload_finalclearanceuploadedit').click() 3074 self.assertTrue( 3075 'href="http://localhost/app/students/K1000000/routingslip.pdf"' 3076 in self.browser.contents) 3077 self.assertTrue( 3078 'File routingslip.pdf uploaded' in self.browser.contents) 3079 self.browser.getLink("Download Final Clearance Document").click() 3080 self.assertEqual(self.browser.headers['Status'], '200 Ok') 3081 self.assertEqual(self.browser.headers['Content-Type'], 3082 'application/pdf') 3083 path = os.path.join(samples_dir(), 'final_clearance_slip.pdf') 3084 open(path, 'wb').write(self.browser.contents) 3085 print "Sample PDF final_clearance_slip.pdf written to %s" % path 3086 return 3087 3060 3088 def test_student_course_registration(self): 3061 3089 # Student cant login if their password is not set -
main/waeup.kofa/trunk/src/waeup/kofa/students/utils.py
r17868 r17917 1268 1268 1269 1269 def final_clearance_enabled(self, student): 1270 # disabled in base package 1270 # disabled in base package but can be enabled in tests 1271 if getattr(student,'browsertest', None) == True: 1272 return True 1271 1273 return False 1272 1274 -
main/waeup.kofa/trunk/src/waeup/kofa/students/viewlets.py
r17867 r17917 32 32 OnlinePaymentDisplayFormPage, BedTicketDisplayFormPage, 33 33 StudentClearanceEditFormPage, StudentPersonalEditFormPage, 34 PaymentsManageFormPage, StudyCourseTranscriptPage) 34 PaymentsManageFormPage, StudyCourseTranscriptPage, 35 StudentFinalClearanceUploadPage) 35 36 from waeup.kofa.students.interfaces import ( 36 37 IStudentsContainer, IStudent, IStudentStudyCourse, IStudentStudyLevel, … … 897 898 "The electronic signature replaces your handwritten signature.\\n\\n" 898 899 "You really want to sign the transcript?'") 900 901 class FinalClearanceSlipActionButton(ManageActionButton): 902 grok.order(1) 903 grok.context(IStudent) 904 grok.view(StudentFinalClearanceUploadPage) 905 grok.require('waeup.viewStudent') 906 icon = 'actionicon_pdf.png' 907 text = _('Download Final Clearance Document') 908 target = 'final_clearance_slip.pdf' 909 910 @property 911 def target_url(self): 912 final_slip = getUtility(IExtFileStore).getFileByContext( 913 self.context.student, attr='routingslip.pdf') 914 if final_slip: 915 return self.view.url(self.view.context, self.target) 916 return False 899 917 900 918
Note: See TracChangeset for help on using the changeset viewer.