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

Add view and viewlet for customer document transitions.

File:
1 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
Note: See TracChangeset for help on using the changeset viewer.