Ignore:
Timestamp:
3 Nov 2021, 15:38:36 (3 years ago)
Author:
Henrik Bettermann
Message:

Customize admission letter.

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  
    1717##
    1818import grok
     19import os
    1920from zope.i18n import translate
    2021from zope.schema.interfaces import ConstraintNotSatisfied
     
    2930    StudentBasePDFFormPage, ExportPDFCourseRegistrationSlip,
    3031    CourseTicketDisplayFormPage, StudentTriggerTransitionFormPage,
     32    ExportPDFAdmissionSlip,
    3133    msave, emit_lock_message)
    3234from waeup.kofa.students.interfaces import IStudentsUtils, ICourseTicket
     
    4648from kofacustom.edocons.interfaces import MessageFactory as _
    4749
     50class 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 = '''
     59You 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
     611. Good behavior
     622. Renunciation of cultism
     63
     64Others are:
     65
     661. Letter of sponsorship
     672. Acceptance letter
     68
     69Please visit the College Registry (student affairs division) for more enquiries.
     70
     71Congratulations!
     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  
    3131from waeup.kofa.students.accommodation import BedTicket
    3232from waeup.kofa.testing import FunctionalTestCase
     33from waeup.kofa.browser.tests.test_pdf import samples_dir
    3334from waeup.kofa.interfaces import (
    3435    IExtFileStore, IFileStoreNameChooser)
     
    4445    def test_dummytest(self):
    4546        return
     47
     48class 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.