Ignore:
Timestamp:
21 Dec 2015, 08:43:49 (9 years ago)
Author:
Henrik Bettermann
Message:

Customize application slip for affiliation programmes.

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

    r12085 r13552  
    2222from zope.component import getUtility, createObject
    2323from zope.security import checkPermission
     24from zope.i18n import translate
    2425from hurry.workflow.interfaces import IWorkflowState
    2526from waeup.kofa.browser.layout import action, UtilityView
    26 from waeup.kofa.interfaces import IExtFileStore
     27from waeup.kofa.interfaces import IExtFileStore, IKofaUtils
    2728from waeup.kofa.applicants.browser import (
    2829    ApplicantRegistrationPage, ApplicantsContainerPage,
     
    3637    NigeriaApplicantManageFormPage,
    3738    NigeriaPDFApplicationSlip)
     39from waeup.kofa.applicants.pdf import PDFApplicationSlip
    3840from waeup.uniben.applicants.interfaces import (
    3941    ICustomApplicant)
     
    231233    """ Approval view
    232234    """
    233 
    234235
    235236    def update(self):
     
    263264    """
    264265
    265 
    266266    def update(self):
    267267        super(CustomExportPDFPageApplicationSlip, self).update()
     
    273273            return self.redirect(self.url(self.context))
    274274        return
     275
     276class CustomPDFApplicationSlip(PDFApplicationSlip):
     277
     278    @property
     279    def title(self):
     280        container_title = self.context.__parent__.title
     281        portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE
     282        ar_translation = translate(_('Application Record'),
     283            'waeup.kofa', target_language=portal_language)
     284        if 'affilasa' in self.target:
     285            return 'Federal College of Education (Technical) Asaba - %s %s %s' % (
     286                container_title, ar_translation,
     287                self.context.application_number)
     288        if 'affilako' in self.target:
     289            return 'Federal College of Education (Technical) Akoka - %s %s %s' % (
     290                container_title, ar_translation,
     291                self.context.application_number)
     292        return '%s - %s %s' % (container_title,
     293            ar_translation, self.context.application_number)
  • main/waeup.uniben/trunk/src/waeup/uniben/applicants/tests/test_browser.py

    r13081 r13552  
    1919Test the applicant-related UI components.
    2020"""
     21import os
    2122from StringIO import StringIO
    2223from datetime import datetime
    2324from hurry.workflow.interfaces import IWorkflowInfo, IWorkflowState
    2425from zope.securitypolicy.interfaces import IPrincipalRoleManager
     26from waeup.kofa.browser.tests.test_pdf import samples_dir
     27from waeup.kofa.applicants.container import ApplicantsContainer
    2528from waeup.uniben.testing import FunctionalLayer
    2629from waeup.uniben.configuration import CustomSessionConfiguration
     
    160163                         'application/pdf')
    161164        return
     165
     166    def test_asaba_application_slip(self):
     167
     168        # Remove required FieldProperty attribute first ...
     169        delattr(ApplicantsContainer, 'prefix')
     170        # ... and replace by asaba
     171        self.applicantscontainer.prefix = 'affilasa'
     172        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
     173        self.slip_path = self.view_path + '/application_slip.pdf'
     174        self.browser.open(self.manage_path)
     175        self.assertEqual(self.browser.headers['Status'], '200 Ok')
     176        self.fill_correct_values()
     177        self.browser.getControl("Save").click()
     178        IWorkflowState(self.applicant).setState('submitted')
     179        self.browser.open(self.manage_path)
     180        self.browser.getLink("Download application slip").click()
     181        self.assertEqual(self.browser.headers['Status'], '200 Ok')
     182        self.assertEqual(self.browser.headers['Content-Type'],
     183                         'application/pdf')
     184        path = os.path.join(samples_dir(), 'application_slip.pdf')
     185        open(path, 'wb').write(self.browser.contents)
     186        print "Sample application_slip.pdf written to %s" % path
  • main/waeup.uniben/trunk/src/waeup/uniben/applicants/utils.py

    r13550 r13552  
    4848        'pre': ['Pre-Degree Studies', 'PRE'],
    4949        'cbt': ['UNIBEN CBT Practice Test', 'CBT'],
    50         'asaba': ['Asaba Programmes', 'ASA'],
    51         'akoka': ['Akoka Programmes', 'AKO'],
     50        'affilasa': ['Asaba Programmes', 'ASA'],
     51        'affilako': ['Akoka Programmes', 'AKO'],
    5252        }
    5353
Note: See TracChangeset for help on using the changeset viewer.