Changeset 14147 for main


Ignore:
Timestamp:
1 Sep 2016, 15:33:23 (8 years ago)
Author:
Henrik Bettermann
Message:

Implement screening invitation letter.

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

Legend:

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

    r14141 r14147  
    3131    ApplicationFeePaymentAddPage,
    3232    OnlinePaymentApprovePage,
    33     ExportPDFPageApplicationSlip)
     33    ExportPDFPageApplicationSlip,
     34    ApplicantBaseDisplayFormPage)
     35from waeup.kofa.students.interfaces import IStudentsUtils
    3436from waeup.kofa.applicants.interfaces import (
    3537    ISpecialApplicant, IApplicantsUtils)
     
    609611        return '%s - %s %s' % (container_title,
    610612            ar_translation, self.context.application_number)
     613
     614class ExportScreeningInvitationSlip(UtilityView, grok.View):
     615    """Deliver a PDF slip of the context.
     616    """
     617    grok.context(ICustomApplicant)
     618    grok.name('screening_invitation_slip.pdf')
     619    grok.require('waeup.viewApplication')
     620    form_fields = None
     621    label = u'Invitation Letter for Screening'
     622
     623
     624    @property
     625    def note(self):
     626        if self.context.screening_date:
     627            return """
     628<br /><br /><br /><br /><font size='12'>
     629Dear %s,
     630<br /><br /><br />
     631You are invited for your Uniben Admission Screening Exercise on:
     632<br /><br />
     633<strong>%s</strong>.
     634<br /><br />
     635Please bring along this letter of invitation to the University Main Auditorium
     636<br /><br />
     637on your screening date.
     638<br /><br /><br />
     639Signed,
     640<br /><br />
     641The Registrar<br />
     642</font>
     643
     644""" % (self.context.display_fullname, self.context.screening_date)
     645        return
     646
     647    def update(self):
     648        if not self.context.screening_date:
     649            self.flash(_('Forbidden'), type="warning")
     650            self.redirect(self.url(self.context))
     651
     652    def render(self):
     653        applicantview = ApplicantBaseDisplayFormPage(self.context, self.request)
     654        students_utils = getUtility(IStudentsUtils)
     655        return students_utils.renderPDF(self,'screening_invitation_slip.pdf',
     656            self.context, applicantview, note=self.note)
  • main/waeup.uniben/trunk/src/waeup/uniben/applicants/tests/test_browser.py

    r14064 r14147  
    168168        return
    169169
    170     def test_application_slip(self):
     170    def test_application_slips(self):
    171171
    172172        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
     
    185185        open(path, 'wb').write(self.browser.contents)
    186186        print "Sample application_slip.pdf written to %s" % path
     187        # Screening invitation letter is not yet available
     188        self.browser.open(self.view_path)
     189        self.assertFalse('invitation slip' in self.browser.contents)
     190        self.browser.open(self.view_path + '/screening_invitation_slip.pdf')
     191        self.assertTrue('Forbidden' in self.browser.contents)
     192        self.applicant.screening_date = u'any date'
     193        # The invitation letter can be printed
     194        self.browser.open(self.view_path)
     195        self.browser.getLink("invitation").click()
     196        self.assertEqual(self.browser.headers['Status'], '200 Ok')
     197        self.assertEqual(self.browser.headers['Content-Type'],
     198                         'application/pdf')
     199        path = os.path.join(samples_dir(), 'screening_invitation_slip.pdf')
     200        open(path, 'wb').write(self.browser.contents)
     201        print "Sample screening_invitation_slip.pdf written to %s" % path
    187202
    188203    def test_akoka_application_slip(self):
  • main/waeup.uniben/trunk/src/waeup/uniben/applicants/viewlets.py

    r11784 r14147  
    1717##
    1818
     19import grok
     20from waeup.kofa.browser.viewlets import ManageActionButton
    1921from waeup.kofa.applicants.viewlets import PDFActionButton
     22from waeup.uniben.applicants.interfaces import ICustomApplicant
     23from waeup.uniben.interfaces import MessageFactory as _
    2024
    2125class CustomPDFActionButton(PDFActionButton):
     
    3236            return
    3337        return self.view.url(self.view.context, self.target)
     38
     39class ScreeningInvitationSlipActionButton(ManageActionButton):
     40    grok.order(4)
     41    grok.context(ICustomApplicant)
     42    grok.require('waeup.viewApplication')
     43    icon = 'actionicon_pdf.png'
     44    text = _('Download screening invitation slip')
     45    target = 'screening_invitation_slip.pdf'
     46
     47    @property
     48    def target_url(self):
     49        if self.context.screening_date:
     50            return self.view.url(self.view.context, self.target)
     51        return False
Note: See TracChangeset for help on using the changeset viewer.