Changeset 16251 for main


Ignore:
Timestamp:
29 Sep 2020, 06:31:26 (4 years ago)
Author:
Henrik Bettermann
Message:

Implement ExportPDFPersonalDataSlip (without button
in the base package). Rename ExportPDFBaseDataPlusSlip
ExportPDFStudyCourseBaseDataSlip.

Location:
main/waeup.kofa/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/CHANGES.txt

    r16243 r16251  
    441.6.1.dev0 (unreleased)
    55=======================
     6
     7* Implement `ExportPDFPersonalDataSlip` (without button
     8  in the base package). Rename `ExportPDFBaseDataPlusSlip`
     9  `ExportPDFStudyCourseBaseDataSlip`.
    610
    711* Save email address provided by mandate when referee report
  • main/waeup.kofa/trunk/src/waeup/kofa/students/browser.py

    r16194 r16251  
    702702            mapping = {'a':self.context.display_fullname})
    703703
    704 class ExportPDFBaseDataPlusSlip(UtilityView, grok.View):
     704class ExportPDFStudyCourseBaseDataSlip(UtilityView, grok.View):
    705705    """Deliver a PDF base and studycourse data slip.
    706706    """
    707707    grok.context(IStudentStudyCourse)
    708     grok.name('basedata_slip.pdf')
     708    grok.name('studycourse_slip.pdf')
    709709    grok.require('waeup.viewStudent')
    710710    prefix = 'form'
     
    740740            self.context.student, studentview,
    741741            omit_fields=self.omit_fields)
     742
     743class ExportPDFPersonalDataSlip(UtilityView, grok.View):
     744    """Deliver a PDF base and personal data slip.
     745    """
     746    grok.context(IStudent)
     747    grok.name('personal_slip.pdf')
     748    grok.require('waeup.viewStudent')
     749    prefix = 'form'
     750
     751    omit_fields = (
     752        'suspended',
     753        'adm_code', 'suspended_comment',
     754        'current_level',
     755        'flash_notice', 'entry_session',
     756        'parents_email')
     757
     758    form_fields = grok.AutoFields(IStudentPersonal)
     759
     760    @property
     761    def title(self):
     762        portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE
     763        return translate(_('Personal Data'), 'waeup.kofa',
     764            target_language=portal_language)
     765
     766    @property
     767    def label(self):
     768        portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE
     769        return translate(_('Personal Data of'),
     770            'waeup.kofa', target_language=portal_language) \
     771            + ' %s' % self.context.student.display_fullname
     772
     773    def render(self):
     774        studentview = StudentBasePDFFormPage(self.context.student,
     775            self.request, self.omit_fields)
     776        students_utils = getUtility(IStudentsUtils)
     777        return students_utils.renderPDF(
     778            self, 'personal_slip.pdf',
     779            self.context.student, studentview,
     780            omit_fields=self.omit_fields)
     781
    742782
    743783class ExportPDFClearanceSlip(grok.View):
  • main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py

    r16248 r16251  
    27682768        return
    27692769
    2770     def test_student_basedata_slip(self):
     2770    def test_student_studycourse_slip(self):
    27712771        IWorkflowState(self.student).setState('school fee paid')
    27722772        self.browser.open(self.login_path)
     
    27742774        self.browser.getControl(name="form.password").value = 'spwd'
    27752775        self.browser.getControl("Login").click()
    2776         # Students can open base data slip
     2776        # Students can open study course base data slip
    27772777        # (no button available in base package)
    2778         pdf_url = '%s/basedata_slip.pdf' % self.studycourse_path
     2778        pdf_url = '%s/studycourse_slip.pdf' % self.studycourse_path
    27792779        self.browser.open(pdf_url)
    27802780        self.assertEqual(self.browser.headers['Status'], '200 Ok')
    27812781        self.assertEqual(self.browser.headers['Content-Type'], 'application/pdf')
    2782         path = os.path.join(samples_dir(), 'basedata_slip.pdf')
     2782        path = os.path.join(samples_dir(), 'studycourse_slip.pdf')
    27832783        open(path, 'wb').write(self.browser.contents)
    2784         print "Sample PDF basedata_slip.pdf written to %s" % path
     2784        print "Sample PDF studycourse_slip.pdf written to %s" % path
     2785
     2786    def test_student_personal_slip(self):
     2787        IWorkflowState(self.student).setState('school fee paid')
     2788        self.browser.open(self.login_path)
     2789        self.browser.getControl(name="form.login").value = self.student_id
     2790        self.browser.getControl(name="form.password").value = 'spwd'
     2791        self.browser.getControl("Login").click()
     2792        # Students can personal data slip
     2793        # (no button available in base package)
     2794        pdf_url = '%s/personal_slip.pdf' % self.student_path
     2795        self.browser.open(pdf_url)
     2796        self.assertEqual(self.browser.headers['Status'], '200 Ok')
     2797        self.assertEqual(self.browser.headers['Content-Type'], 'application/pdf')
     2798        path = os.path.join(samples_dir(), 'personal_slip.pdf')
     2799        open(path, 'wb').write(self.browser.contents)
     2800        print "Sample PDF personal_slip.pdf written to %s" % path
    27852801
    27862802    def test_student_clearance(self):
Note: See TracChangeset for help on using the changeset viewer.