Ignore:
Timestamp:
24 Apr 2014, 06:17:10 (11 years ago)
Author:
Henrik Bettermann
Message:

Special application procedure modified. Special applicants must submit
their form before they can download payment slips. Thus the regular
workflow is now applied but, in contrast to regular applications,
special applicants can create and pay more than one payment ticket.
Also application slips are hidden.

Location:
main/waeup.kofa/trunk/src/waeup/kofa/applicants
Files:
7 edited

Legend:

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

    r11580 r11599  
    491491    def form_fields(self):
    492492        if self.context.special:
    493             form_fields = grok.AutoFields(ISpecialApplicant)
     493            form_fields = grok.AutoFields(ISpecialApplicant).omit('locked')
    494494        else:
    495495            form_fields = grok.AutoFields(IApplicant).omit(
     
    728728
    729729    def render(self):
    730         #if self.context.p_state != 'paid':
    731         #    self.flash(_('Ticket not yet paid.'))
    732         #    self.redirect(self.url(self.context))
    733         #    return
     730        if self.context.__parent__.special \
     731            and self.context.__parent__.state != SUBMITTED:
     732            self.flash(_('Please pay and submit before '
     733                         'trying to download payment slips.'))
     734            self.redirect(self.url(self.context))
     735            return
    734736        applicantview = ApplicantBaseDisplayFormPage(self.context.__parent__,
    735737            self.request)
     
    948950    def form_fields(self):
    949951        if self.context.special:
    950             form_fields = grok.AutoFields(ISpecialApplicant)
     952            form_fields = grok.AutoFields(ISpecialApplicant).omit('locked')
    951953            form_fields['applicant_id'].for_display = True
    952954        else:
     
    965967        if state == STARTED:
    966968            actions = [[_('Save')],
     969                [_('Add online payment ticket'),_('Remove selected tickets')]]
     970        elif self.context.special and state == PAID:
     971            actions = [[_('Save'), _('Final Submit')],
    967972                [_('Add online payment ticket'),_('Remove selected tickets')]]
    968973        elif state == PAID:
  • main/waeup.kofa/trunk/src/waeup/kofa/applicants/browser_templates/applicantdisplaypage.pt

    r11254 r11599  
    3838  </tbody>
    3939</table>
    40 <h3  i18n:domain="waeup.kofa" i18n:translate="">
    41     Application Fee Payment Tickets
     40<h3 i18n:domain="waeup.kofa" i18n:translate="">
     41    Payment Tickets
    4242</h3>
    4343<table i18n:domain="waeup.kofa" class="table table-condensed">
  • main/waeup.kofa/trunk/src/waeup/kofa/applicants/browser_templates/applicanteditpage.pt

    r11578 r11599  
    8989  <br /><br />
    9090  <h3 i18n:translate="">
    91       Application Fee Payment Tickets
     91      Payment Tickets
    9292  </h3>
    9393
  • main/waeup.kofa/trunk/src/waeup/kofa/applicants/interfaces.py

    r10846 r11599  
    490490        )
    491491
     492    locked = schema.Bool(
     493        title = _(u'Form locked'),
     494        default = False,
     495        required = False,
     496        )
     497
    492498    applicant_id = schema.TextLine(
    493499        title = _(u'Applicant Id'),
  • main/waeup.kofa/trunk/src/waeup/kofa/applicants/payment.py

    r11580 r11599  
    2929from waeup.kofa.payments.interfaces import IPayer
    3030from waeup.kofa.applicants.interfaces import IApplicantOnlinePayment
     31from waeup.kofa.applicants.workflow import PAID
    3132from waeup.kofa.utils.helpers import attrs_to_fields
    3233
     
    4445        """Process applicant after payment was approved.
    4546        """
    46         if not self.__parent__.special:
     47        if not (self.__parent__.special and self.__parent__.state == PAID):
    4748            wf_info = IWorkflowInfo(self.__parent__)
    4849            try:
     
    5960        """Process applicant after payment was made.
    6061        """
    61         if not self.__parent__.special:
     62        if not (self.__parent__.special and self.__parent__.state == PAID):
    6263            wf_info = IWorkflowInfo(self.__parent__)
    6364            try:
  • main/waeup.kofa/trunk/src/waeup/kofa/applicants/tests/test_browser.py

    r11575 r11599  
    5555container_name_2 = u'app%s' % session_2
    5656
     57SAMPLE_IMAGE = os.path.join(os.path.dirname(__file__), 'test_image.jpg')
     58
    5759class ApplicantsFullSetup(FunctionalTestCase):
    5860    # A test case that only contains a setup and teardown
     
    976978            '<span>200.0</span>' in self.browser.contents)
    977979        self.assertEqual(len(self.special_applicant.keys()), 1)
    978         # The applicant's workflow remain started ...
     980        # The applicant's workflow state is paid ...
    979981        self.special_applicant.values()[0].approveApplicantPayment()
    980         self.assertEqual(self.special_applicant.state, 'started')
     982        self.assertEqual(self.special_applicant.state, 'paid')
    981983        self.browser.open(applicant_path + '/edit')
    982         # ... so that he can create further tickets.
     984        # ... but he can create further tickets.
    983985        self.browser.getControl(name="form.special_application").value = [
    984986            'clearance']
     
    991993            '<td>Acceptance Fee</td>' in self.browser.contents)
    992994        self.assertEqual(len(self.special_applicant.keys()), 2)
     995        # Second payment can also be approved wthout error message
     996        flashtype, msg, log = self.special_applicant.values()[1].approveApplicantPayment()
     997        self.assertEqual(flashtype, 'success')
     998        self.assertEqual(msg, 'Payment approved')
     999        # Payment slips can't be downloaded ...
     1000        payment_id = self.special_applicant.keys()[0]
     1001        self.browser.open(applicant_path + '/' + payment_id)
     1002        self.browser.getLink("Download payment slip").click()
     1003        self.assertTrue(
     1004            'Please pay and submit before trying to download payment slips.'
     1005            in self.browser.contents)
     1006        # ... unless form is submitted.
     1007        self.browser.open(applicant_path + '/edit')
     1008        image = open(SAMPLE_IMAGE, 'rb')
     1009        ctrl = self.browser.getControl(name='form.passport')
     1010        file_ctrl = ctrl.mech_control
     1011        file_ctrl.add_file(image, filename='myphoto.jpg')
     1012        self.browser.getControl(name="confirm_passport").value = True
     1013        self.browser.getControl("Final Submit").click()
     1014        self.browser.open(applicant_path + '/' + payment_id)
     1015        self.browser.getLink("Download payment slip").click()
     1016        self.assertEqual(self.browser.headers['Content-Type'],
     1017                 'application/pdf')
    9931018        return
    9941019
     
    10221047        self.assertTrue(
    10231048            'No passport picture uploaded' in self.browser.contents)
    1024         # Create a pseudo image file and select it to be uploaded in form
    1025         pseudo_image = StringIO('I pretend to be a graphics file')
     1049        # Use a real image file and select it to be uploaded in form
     1050        image = open(SAMPLE_IMAGE, 'rb')
    10261051        ctrl = self.browser.getControl(name='form.passport')
    10271052        file_ctrl = ctrl.mech_control
    1028         file_ctrl.add_file(pseudo_image, filename='myphoto.jpg')
     1053        file_ctrl.add_file(image, filename='myphoto.jpg')
    10291054        self.browser.getControl("Final Submit").click() # (finally) submit form
    10301055        # The picture has been uploaded but the form cannot be submitted
  • main/waeup.kofa/trunk/src/waeup/kofa/applicants/viewlets.py

    r10802 r11599  
    214214        """Get a URL to the target...
    215215        """
    216         if self.context.state in ('initialized', 'started', 'paid'):
     216        if self.context.state in ('initialized', 'started', 'paid') \
     217            or self.context.special:
    217218            return
    218219        return self.view.url(self.view.context, self.target)
Note: See TracChangeset for help on using the changeset viewer.