Ignore:
Timestamp:
10 Jun 2012, 20:13:34 (12 years ago)
Author:
Henrik Bettermann
Message:

Disable application slip download in state initialized (managers only) and started.

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

Legend:

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

    r8665 r8666  
    711711    prefix = 'form'
    712712
     713    def update(self):
     714        if self.context.state in ('initialized', 'started'):
     715            self.flash(
     716                _('Please pay before trying to download the application slip.'))
     717            return self.redirect(self.url(self.context))
     718        return
     719
    713720    def render(self):
    714721        pdfstream = getAdapter(self.context, IPDF, name='application_slip')(
  • main/waeup.kofa/trunk/src/waeup/kofa/applicants/tests/test_browser.py

    r8665 r8666  
    460460        self.browser.getControl("Save").click()
    461461        self.assertMatches('...Form has been saved...', self.browser.contents)
    462         # Open pdf slip
     462        # Pdf slip can't be opened and download button is not available
     463        self.assertFalse('Download application slip' in self.browser.contents)
    463464        self.browser.open(self.slip_path)
     465        self.assertTrue(
     466            'Please pay before trying to download the application slip.'
     467            in self.browser.contents)
     468        # If applicant is in correct state the pdf slip can be opened.
     469        IWorkflowState(self.applicant).setState('paid')
     470        self.browser.open(self.manage_path)
     471        self.browser.getLink("Download application slip").click()
    464472        self.assertEqual(self.browser.headers['Status'], '200 Ok')
    465473        self.assertEqual(self.browser.headers['Content-Type'],
     
    743751        self.assertMatches('...started...',
    744752                           self.browser.contents)
    745         state = IWorkflowState(self.applicant).getState()
    746         self.assertTrue(state == 'started')
     753        self.assertTrue(self.applicant.state == 'started')
    747754        # Let's logout and approve the payment as manager
    748755        self.browser.getLink("Logout").click()
     
    759766        self.assertEqual(payment.r_amount_approved, 200.0)
    760767        self.assertEqual(payment.r_code, 'AP')
    761         state = IWorkflowState(self.applicant).getState()
    762         self.assertTrue(state == 'paid')
     768        self.assertTrue(self.applicant.state == 'paid')
    763769        return
    764770
  • main/waeup.kofa/trunk/src/waeup/kofa/applicants/viewlets.py

    r8665 r8666  
    1717##
    1818import grok
    19 from hurry.workflow.interfaces import IWorkflowState
    2019from waeup.kofa.interfaces import IKofaObject
    2120from waeup.kofa.students.viewlets import PrimaryStudentNavTab
     
    171170    target = 'application_slip.pdf'
    172171
     172    @property
     173    def target_url(self):
     174        """Get a URL to the target...
     175        """
     176        if self.context.state in ('initialized', 'started'):
     177            return
     178        return self.view.url(self.view.context, self.target)
     179
    173180class StudentCreateActionButton(ManageActionButton):
    174181    grok.order(4)
     
    183190        """Get a URL to the target...
    184191        """
    185         if IWorkflowState(self.context).getState() != 'admitted':
     192        if self.context.state != 'admitted':
    186193            return
    187194        return self.view.url(self.view.context, self.target)
Note: See TracChangeset for help on using the changeset viewer.