Ignore:
Timestamp:
21 Nov 2014, 13:05:56 (10 years ago)
Author:
Henrik Bettermann
Message:

Add view and viewlet for customer document transitions.

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

Legend:

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

    r12018 r12028  
    378378
    379379class CustomerTriggerTransitionFormPage(IkobaEditFormPage):
    380     """ View to manage customer base data
     380    """ View to trigger customer workflow transitions
    381381    """
    382382    grok.context(ICustomer)
     
    793793        return
    794794
     795
    795796class DocumentEditFormPage(DocumentManageFormPage):
    796797    """ Page to edit a document
    797798    """
    798     grok.context(ICustomerDocument)
    799799    grok.name('edit')
    800800    grok.require('waeup.handleCustomer')
    801     form_fields = grok.AutoFields(ICustomerDocument)
    802     pnav = 4
    803801
    804802    def update(self):
     
    807805            return
    808806        return super(DocumentEditFormPage, self).update()
     807
     808
     809class DocumentTriggerTransitionFormPage(IkobaEditFormPage):
     810    """ View to trigger customer document transitions
     811    """
     812    grok.context(ICustomerDocument)
     813    grok.name('trigtrans')
     814    grok.require('waeup.triggerTransition')
     815    grok.template('trigtrans')
     816    label = _('Trigger document transition')
     817    pnav = 4
     818
     819    def update(self):
     820        return super(IkobaEditFormPage, self).update()
     821
     822    def getTransitions(self):
     823        """Return a list of dicts of allowed transition ids and titles.
     824
     825        Each list entry provides keys ``name`` and ``title`` for
     826        internal name and (human readable) title of a single
     827        transition.
     828        """
     829        wf_info = IWorkflowInfo(self.context)
     830        allowed_transitions = [t for t in wf_info.getManualTransitions()]
     831        return [dict(name='', title=_('No transition'))] +[
     832            dict(name=x, title=y) for x, y in allowed_transitions]
     833
     834    @action(_('Save'), style='primary')
     835    def save(self, **data):
     836        form = self.request.form
     837        if 'transition' in form and form['transition']:
     838            transition_id = form['transition']
     839            wf_info = IWorkflowInfo(self.context)
     840            wf_info.fireTransition(transition_id)
     841        return
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/browser_templates/trigtrans.pt

    r11967 r12028  
    33      autocomplete="off">
    44
     5    <br />
    56
    67    <select id="transition" name="transition" class="form-control half">
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests/test_browser.py

    r12020 r12028  
    294294        self.assertEqual(self.browser.headers['Status'], '200 Ok')
    295295        self.assertEqual(self.browser.url, self.customer_path)
    296         self.browser.getLink("Trigger").click()
     296        self.browser.getLink("Transition").click()
    297297        self.assertEqual(self.browser.headers['Status'], '200 Ok')
    298298        # Managers can trigger transitions
     
    800800        self.assertEqual(self.browser.url, self.documents_path + '/d102/index')
    801801
     802        # Transitions can be performed
     803        self.browser.getLink("Transition").click()
     804        self.browser.getControl(name="transition").value = ['submit']
     805        self.browser.getControl("Save").click()
     806        self.browser.getControl(name="transition").value = ['verify']
     807        self.browser.getControl("Save").click()
     808        self.assertEqual(document.state, 'verified')
     809
    802810        # Documents can be removed
    803811        self.browser.getLink("Documents").click()
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/viewlets.py

    r12018 r12028  
    202202    grok.require('waeup.triggerTransition')
    203203    icon = 'actionicon_trigtrans.png'
    204     text = _(u'Trigger transition')
     204    text = _(u'Transition')
    205205    target = 'trigtrans'
    206206
     
    323323
    324324
     325class DocumentTrigTransActionButton(ManageActionButton):
     326    grok.order(2)
     327    grok.context(ICustomerDocument)
     328    grok.view(DocumentDisplayFormPage)
     329    grok.require('waeup.triggerTransition')
     330    icon = 'actionicon_trigtrans.png'
     331    text = _(u'Transition')
     332    target = 'trigtrans'
     333
     334
    325335class DocumentViewActionButton(ManageActionButton):
    326336    grok.order(1)
Note: See TracChangeset for help on using the changeset viewer.