Changeset 15580 for main


Ignore:
Timestamp:
4 Sep 2019, 08:26:25 (5 years ago)
Author:
Henrik Bettermann
Message:

Customize ApplicantBaseDisplayFormPage? and CustomExportPDFPaymentSlipPage.

File:
1 edited

Legend:

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

    r15579 r15580  
    3434    ExportJobContainerOverview,
    3535    ExportJobContainerJobStart,
    36     ExportJobContainerDownload)
     36    ExportJobContainerDownload,
     37    ApplicantBaseDisplayFormPage)
    3738from waeup.kofa.browser.viewlets import ManageActionButton
    3839from waeup.kofa.applicants.viewlets import (
     
    4041from waeup.kofa.applicants.pdf import PDFApplicationSlip
    4142from waeup.kofa.applicants.workflow import ADMITTED, PAID, STARTED
     43from waeup.kofa.students.interfaces import IStudentsUtils
    4244from kofacustom.nigeria.applicants.interfaces import (
    4345    UG_OMIT_DISPLAY_FIELDS,
     
    4648    UG_OMIT_EDIT_FIELDS
    4749    )
     50from kofacustom.nigeria.applicants.browser import (
     51    NigeriaExportPDFPaymentSlipPage)
    4852from kofacustom.dspg.applicants.interfaces import (
    4953    ICustomUGApplicant, ICustomUGApplicantEdit,
    5054    ICustomSpecialApplicant,
     55    ICustomApplicantOnlinePayment,
     56    ICustomApplicant,
    5157    ND_OMIT_DISPLAY_FIELDS,
    5258    ND_OMIT_PDF_FIELDS,
     
    355361            return _('Upload your passport photo before making payment.')
    356362        return ''
     363
     364class CustomApplicantBaseDisplayFormPage(ApplicantBaseDisplayFormPage):
     365
     366    grok.context(ICustomApplicant)
     367
     368    @property
     369    def form_fields(self):
     370        if self.context.__parent__.prefix in ('conv', 'special'):
     371            form_fields = grok.AutoFields(ICustomApplicant).select(
     372                'applicant_id', 'reg_number', 'email')
     373            form_fields['reg_number'].field.title = u'Identification Number'
     374            return form_fields
     375        form_fields = grok.AutoFields(ICustomApplicant).select(
     376            'applicant_id', 'reg_number', 'email', 'course1')
     377        return form_fields
     378
     379class CustomExportPDFPaymentSlipPage(NigeriaExportPDFPaymentSlipPage):
     380    """Deliver a PDF slip of the context.
     381    """
     382
     383    grok.context(ICustomApplicantOnlinePayment)
     384
     385    @property
     386    def form_fields(self):
     387        form_fields = grok.AutoFields(ICustomApplicantOnlinePayment).omit(
     388            'ac', 'provider_amt', 'gateway_amt', 'thirdparty_amt', 'p_item',
     389            'p_split_data')
     390        form_fields['creation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
     391        form_fields['payment_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
     392        if self.context.__parent__.__parent__.prefix in ('conv', 'special'):
     393            form_fields = form_fields.omit('p_session')
     394        return form_fields
     395
     396    def render(self):
     397        if self.payment_slip_download_warning:
     398            self.flash(self.payment_slip_download_warning, type='danger')
     399            self.redirect(self.url(self.context))
     400            return
     401        applicantview = CustomApplicantBaseDisplayFormPage(self.context.__parent__,
     402            self.request)
     403        students_utils = getUtility(IStudentsUtils)
     404        return students_utils.renderPDF(self,'payment_slip.pdf',
     405            self.context.__parent__, applicantview, note=self.note)
Note: See TracChangeset for help on using the changeset viewer.