Ignore:
Timestamp:
10 Jul 2022, 18:21:55 (2 years ago)
Author:
Henrik Bettermann
Message:

Customize payment slip.

Add social media meta data.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/kofacustom.lpng/trunk/src/kofacustom/lpng/applicants/browser.py

    r17019 r17020  
    2020import grok
    2121from zope.formlib.textwidgets import BytesDisplayWidget
     22from zope.component import getUtility
     23from waeup.kofa.widgets.datewidget import (
     24    FriendlyDateDisplayWidget,
     25    FriendlyDatetimeDisplayWidget)
    2226from waeup.kofa.applicants.pdf import PDFApplicationSlip
    2327from waeup.kofa.applicants.browser import (
     
    2630    ApplicantManageFormPage,
    2731    ApplicantEditFormPage,
    28     BalancePaymentAddFormPage)
    29 
     32    BalancePaymentAddFormPage,
     33    ExportPDFPaymentSlipPage,
     34    ApplicantBaseDisplayFormPage)
     35from waeup.kofa.students.interfaces import IStudentsUtils
     36from waeup.kofa.applicants.interfaces import IApplicantOnlinePayment
     37from kofacustom.nigeria.applicants.interfaces import INigeriaApplicantOnlinePayment
     38from kofacustom.nigeria.applicants.browser import NigeriaExportPDFPaymentSlipPage
    3039from kofacustom.lpng.applicants.interfaces import (
    3140    ICustomApplicant,
     
    3342    ICustomApplicantEdit,
    3443    )
    35 
    3644from kofacustom.lpng.interfaces import MessageFactory as _
    3745
     
    93101    """
    94102    grok.require('waeup.payApplicant')
     103   
     104class CustomApplicantBaseDisplayFormPage(ApplicantBaseDisplayFormPage):
    95105
     106    @property
     107    def form_fields(self):
     108        form_fields = grok.AutoFields(ICustomApplicant).select(
     109            'applicant_id', 'reg_number', 'email')
     110        return form_fields
     111
     112class CustomExportPDFPaymentSlipPage(NigeriaExportPDFPaymentSlipPage):
     113    """Deliver a PDF slip of the context.
     114    """
     115    # use IApplicantOnlinePayment alternativly
     116    form_fields = grok.AutoFields(INigeriaApplicantOnlinePayment).omit(
     117        'p_item').omit('p_option').omit('p_combi')
     118    form_fields['creation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
     119    form_fields['payment_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
     120
     121    def render(self):
     122        if self.payment_slip_download_warning:
     123            self.flash(self.payment_slip_download_warning, type='danger')
     124            self.redirect(self.url(self.context))
     125            return
     126        applicantview = CustomApplicantBaseDisplayFormPage(self.context.__parent__,
     127            self.request)
     128        students_utils = getUtility(IStudentsUtils)
     129        return students_utils.renderPDF(self,'payment_slip.pdf',
     130            self.context.__parent__, applicantview, note=self.note,
     131            omit_fields=())
Note: See TracChangeset for help on using the changeset viewer.