Ignore:
Timestamp:
5 Dec 2014, 15:43:24 (10 years ago)
Author:
Henrik Bettermann
Message:

Catch InvalidTransitionError? in UI.

Location:
main/waeup.ikoba/trunk/src/waeup/ikoba/customers
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/browser.py

    r12119 r12151  
    3131from zope.formlib.textwidgets import BytesDisplayWidget
    3232from zope.security import checkPermission
    33 from hurry.workflow.interfaces import IWorkflowInfo, IWorkflowState
     33from hurry.workflow.interfaces import (
     34    IWorkflowInfo, IWorkflowState, InvalidTransitionError)
    3435from waeup.ikoba.interfaces import MessageFactory as _
    3536from waeup.ikoba.interfaces import (
     
    12551256            transition_id = form['transition']
    12561257            wf_info = IWorkflowInfo(self.context)
    1257             wf_info.fireTransition(transition_id)
     1258            try:
     1259                wf_info.fireTransition(transition_id)
     1260            except InvalidTransitionError, error:
     1261                self.flash(error, type="warning")
    12581262        return
    12591263
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests/test_browser.py

    r12145 r12151  
    12261226        IWorkflowInfo(self.contract).fireTransition('approve')
    12271227        self.assertEqual(IWorkflowState(self.contract).getState(), 'approved')
    1228         return
    1229 
     1228
     1229
     1230    def test_contract_approval_in_UI(self):
     1231        # Now let's see what the UI says why trying to approve a contract
     1232        # with unverified documents.
     1233        IWorkflowState(self.document).setState('submitted')
     1234        self.contract.document_object = self.document
     1235        IWorkflowState(self.contract).setState('submitted')
     1236        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
     1237        self.browser.open(self.contracts_path + '/c101/trigtrans')
     1238        self.browser.getControl(name="transition").value = ['approve']
     1239        self.browser.getControl("Save").click()
     1240        # InvalidTransitionError is catched
     1241        self.assertTrue(
     1242            '<div class="alert alert-warning">Attached documents must be verified first.</div>'
     1243            in self.browser.contents)
     1244        IWorkflowState(self.document).setState('verified')
     1245        self.browser.getControl(name="transition").value = ['approve']
     1246        self.browser.getControl("Save").click()
     1247        self.assertEqual(IWorkflowState(self.contract).getState(), 'approved')
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/workflow.py

    r12145 r12151  
    252252            IWorkflowState(obj).setState(event.transition.source)
    253253            raise InvalidTransitionError(
    254                 "Documents must be verified first.")
     254                _("Attached documents must be verified first."))
    255255    msg = event.transition.user_data['msg']
    256256    history = IObjectHistory(obj)
Note: See TracChangeset for help on using the changeset viewer.