Changeset 16695 for main/kofacustom.edocons
- Timestamp:
- 3 Nov 2021, 15:38:36 (3 years ago)
- Location:
- main/kofacustom.edocons/trunk/src/kofacustom/edocons/students
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/kofacustom.edocons/trunk/src/kofacustom/edocons/students/browser.py
r16639 r16695 17 17 ## 18 18 import grok 19 import os 19 20 from zope.i18n import translate 20 21 from zope.schema.interfaces import ConstraintNotSatisfied … … 29 30 StudentBasePDFFormPage, ExportPDFCourseRegistrationSlip, 30 31 CourseTicketDisplayFormPage, StudentTriggerTransitionFormPage, 32 ExportPDFAdmissionSlip, 31 33 msave, emit_lock_message) 32 34 from waeup.kofa.students.interfaces import IStudentsUtils, ICourseTicket … … 46 48 from kofacustom.edocons.interfaces import MessageFactory as _ 47 49 50 class CustomExportPDFAdmissionSlip(ExportPDFAdmissionSlip): 51 """Deliver a PDF Admission slip. 52 """ 53 54 omit_fields = ('date_of_birth', 'current_level', 'current_mode', 55 'certificate', 'faculty') 56 #form_fields = grok.AutoFields(IStudentBase).select('student_id', 'reg_number') 57 58 post_text = ''' 59 You are expected to proceed and pay your school fees of before the 12th of Nov. and on resumption you are to present a sworn affidavit on: 60 61 1. Good behavior 62 2. Renunciation of cultism 63 64 Others are: 65 66 1. Letter of sponsorship 67 2. Acceptance letter 68 69 Please visit the College Registry (student affairs division) for more enquiries. 70 71 Congratulations! 72 ''' 73 74 @property 75 def label(self): 76 portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE 77 return translate(_('Admission Letter of'), 78 'waeup.kofa', target_language=portal_language) \ 79 + ' %s' % self.context.display_fullname 80 81 def render(self): 82 students_utils = getUtility(IStudentsUtils) 83 letterhead_path = os.path.join( 84 os.path.dirname(__file__), 'static', 'letterhead_admission.jpg') 85 if not os.path.exists(letterhead_path): 86 letterhead_path = None 87 return students_utils.renderPDFAdmissionLetter(self, 88 self.context.student, omit_fields=self.omit_fields, 89 letterhead_path=letterhead_path, post_text=self.post_text) 90 -
main/kofacustom.edocons/trunk/src/kofacustom/edocons/students/tests/test_browser.py
r16639 r16695 31 31 from waeup.kofa.students.accommodation import BedTicket 32 32 from waeup.kofa.testing import FunctionalTestCase 33 from waeup.kofa.browser.tests.test_pdf import samples_dir 33 34 from waeup.kofa.interfaces import ( 34 35 IExtFileStore, IFileStoreNameChooser) … … 44 45 def test_dummytest(self): 45 46 return 47 48 class StudentUITests(StudentsFullSetup): 49 # Tests for Student class views and pages 50 51 layer = FunctionalLayer 52 53 def test_student_admission_letters(self): 54 self.certificate.study_mode = 'ug_ft' 55 # Student cant login if their password is not set 56 IWorkflowInfo(self.student).fireTransition('admit') 57 self.browser.open(self.login_path) 58 self.browser.getControl(name="form.login").value = self.student_id 59 self.browser.getControl(name="form.password").value = 'spwd' 60 self.browser.getControl("Login").click() 61 self.assertMatches( 62 '...You logged in...', self.browser.contents) 63 self.browser.getLink("Base Data").click() 64 self.browser.getLink("Download admission letter").click() 65 self.assertEqual(self.browser.headers['Status'], '200 Ok') 66 self.assertEqual(self.browser.headers['Content-Type'], 'application/pdf') 67 path = os.path.join(samples_dir(), 'admission_slip.pdf') 68 open(path, 'wb').write(self.browser.contents) 69 print "Sample PDF UG admission_slip.pdf written to %s" % path 70
Note: See TracChangeset for help on using the changeset viewer.