Ignore:
Timestamp:
10 Dec 2011, 06:38:34 (13 years ago)
Author:
Henrik Bettermann
Message:

Catch InvalidTransitionError? and flash error message.

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

Legend:

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

    r7321 r7322  
    2525from zope.component import getUtility, createObject
    2626from zope.formlib.form import setUpEditWidgets
    27 from hurry.workflow.interfaces import IWorkflowInfo, IWorkflowState
     27from hurry.workflow.interfaces import (
     28    IWorkflowInfo, IWorkflowState, InvalidTransitionError)
    2829from reportlab.pdfgen import canvas
    2930from reportlab.lib.units import cm
     
    593594    # from the incoming request.
    594595    def update(self):
    595         if self.context.p_state == 'paid':
    596             self.flash('This ticket has already been paid.')
     596        self.wf_info = IWorkflowInfo(self.context.__parent__)
     597        try:
     598            self.wf_info.fireTransition('pay')
     599        except InvalidTransitionError:
     600            self.flash('Error: %s' % sys.exc_info()[1])
    597601            return
    598602        self.context.r_amount_approved = self.context.amount_auth
     
    604608        self.context.__parent__.loggerInfo(
    605609            ob_class, 'valid callback: %s' % self.context.p_id)
    606         self.wf_info = IWorkflowInfo(self.context.__parent__)
    607         self.wf_info.fireTransition('pay')
    608610        self.flash('Valid callback received.')
    609611        return
  • main/waeup.sirp/trunk/src/waeup/sirp/applicants/tests/test_browser.py

    r7270 r7322  
    619619        # Callback can't be applied twice
    620620        self.browser.open(payment_url + '/callback')
    621         self.assertMatches('...This ticket has already been paid...',
    622                           self.browser.contents)
     621        self.assertMatches(
     622            "...Transition 'pay' requires 'started' as source state...",
     623            self.browser.contents)
    623624        # The payment receipt can be downloaded now
    624625        self.browser.open(payment_url)
Note: See TracChangeset for help on using the changeset viewer.