Changeset 16504


Ignore:
Timestamp:
12 Jun 2021, 05:05:15 (3 years ago)
Author:
Henrik Bettermann
Message:

Show recipient body address on payment slip.

Location:
main/waeup.uniben/trunk/src/waeup/uniben/applicants
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.uniben/trunk/src/waeup/uniben/applicants/browser.py

    r16471 r16504  
    3434    ApplicantBaseDisplayFormPage,
    3535    CheckTranscriptStatus,
    36     AdditionalFile)
     36    AdditionalFile,)
    3737from waeup.kofa.students.interfaces import IStudentsUtils
    3838from waeup.kofa.applicants.interfaces import (
     
    4343    NigeriaApplicantManageFormPage,
    4444    NigeriaApplicantEditFormPage,
    45     NigeriaPDFApplicationSlip)
     45    NigeriaPDFApplicationSlip,
     46    NigeriaExportPDFPaymentSlipPage)
    4647from waeup.uniben.applicants.interfaces import (
    4748    ICustomApplicant,
     
    727728            ar_translation, self.context.application_number)
    728729
     730class CustomApplicantBaseDisplayFormPage(ApplicantBaseDisplayFormPage):
     731
     732    @property
     733    def form_fields(self):
     734        target = getattr(self.context.__parent__, 'prefix', None)
     735        if target.startswith('tsc'):
     736            form_fields = grok.AutoFields(ICustomApplicant).select(
     737                'applicant_id', 'email', 'dispatch_address')
     738        else:
     739            form_fields = grok.AutoFields(ICustomApplicant).select(
     740                'applicant_id', 'reg_number', 'email', 'course1')
     741        if self.context.__parent__.prefix in ('special',):
     742            form_fields['reg_number'].field.title = u'Identification Number'
     743            return form_fields
     744        return form_fields
     745
     746class CustomExportPDFPaymentSlipPage(NigeriaExportPDFPaymentSlipPage):
     747    """Deliver a PDF slip of the context.
     748    """
     749
     750    @property
     751    def omit_fields(self):
     752        target = getattr(self.context.__parent__.__parent__, 'prefix', None)
     753        if target.startswith('tsc'):
     754            return ('date_of_birth', 'course1')
     755        return
     756
     757    @property
     758    def note(self):
     759        return
     760
     761    def render(self):
     762        if self.payment_slip_download_warning:
     763            self.flash(self.payment_slip_download_warning, type='danger')
     764            self.redirect(self.url(self.context))
     765            return
     766        applicantview = CustomApplicantBaseDisplayFormPage(self.context.__parent__,
     767            self.request)
     768        students_utils = getUtility(IStudentsUtils)
     769        return students_utils.renderPDF(self,'payment_slip.pdf',
     770            self.context.__parent__, applicantview,
     771            note=self.note, omit_fields=self.omit_fields)
     772
    729773class ExportScreeningInvitationSlip(UtilityView, grok.View):
    730774    """Deliver a PDF slip of the context.
  • main/waeup.uniben/trunk/src/waeup/uniben/applicants/tests/test_browser.py

    r16330 r16504  
    348348        file_ctrl.add_file(image, filename='myphoto.jpg')
    349349        self.browser.getControl("Save").click()
     350        applicant_url = self.browser.url
    350351        self.browser.getControl("Create and make online").click()
    351352        self.assertTrue('Payment ticket created' in self.browser.contents)
    352353        self.assertTrue('<span>40000.0</span>' in self.browser.contents)
    353354        self.assertEqual(applicant.values()[0].amount_auth, 40000.0)
     355        applicant.values()[0].p_state = 'paid'
     356        payment_url = self.browser.url
    354357        IWorkflowState(applicant).setState('submitted')
     358        self.browser.open(payment_url)
     359        self.browser.getLink("Download payment slip").click()
     360        self.assertEqual(self.browser.headers['Status'], '200 Ok')
     361        self.assertEqual(self.browser.headers['Content-Type'],
     362                         'application/pdf')
     363        path = os.path.join(samples_dir(), 'tscf_payment_slip.pdf')
     364        open(path, 'wb').write(self.browser.contents)
     365        print "Sample tscf_payment_slip.pdf written to %s" % path
     366        self.browser.open(applicant_url)
    355367        self.browser.getLink("My Data").click()
    356368        self.browser.getLink("Download application slip").click()
Note: See TracChangeset for help on using the changeset viewer.