Ignore:
Timestamp:
9 Jun 2011, 16:59:04 (13 years ago)
Author:
Henrik Bettermann
Message:

Fill message attribute with workflow messages and display on forms.

File:
1 edited

Legend:

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

    r6303 r6305  
    2525import grok
    2626
     27from datetime import datetime
    2728from zope.component import getUtility
    2829from zope.formlib.widget import CustomWidgetFactory
     
    7778    MultiListDisplayWidget, subwidget=results_display_widget)
    7879
     80TRANSITION_OBJECTS = create_workflow()
     81
     82TRANSITION_DICT = dict([
     83    (transition_object.transition_id,transition_object.title)
     84    for transition_object in TRANSITION_OBJECTS])
     85
    7986class ApplicantsRootPage(WAeUPPage):
    8087    grok.context(IApplicantsRoot)
     
    416423        if state == INITIALIZED:
    417424            IWorkflowInfo(self.context[pin]).fireTransition('start')
     425            timestamp = datetime.now().strftime("%d/%m/%Y %H:%M")
     426            transition_title = TRANSITION_DICT['start']
     427            self.context[pin].messages += '<br />%s - %s' % (timestamp,transition_title)
    418428        self.redirect(self.url(self.context[pin], 'edit'))
    419429        return
     
    507517    def getTransitions(self):
    508518        allowed_transitions_ids = IWorkflowInfo(self.context).getManualTransitionIds()
    509         transition_objects = create_workflow()
    510519        null_transition = [{'name': '', 'title':'No transition'}]
    511520        transitions = null_transition + [dict(
    512521            name=transition_object.transition_id,
    513522            title=transition_object.title)
    514             for transition_object in transition_objects
     523            for transition_object in TRANSITION_OBJECTS
    515524            if transition_object.transition_id in allowed_transitions_ids]
    516525        #import pdb; pdb.set_trace()
     
    528537        form = self.request.form
    529538        if form.has_key('transition') and form['transition']:
    530             transition = form['transition']
    531             IWorkflowInfo(self.context).fireTransition(transition)
     539            transition_id = form['transition']
     540            IWorkflowInfo(self.context).fireTransition(transition_id)
     541            #import pdb; pdb.set_trace()
     542            timestamp = datetime.now().strftime("%d/%m/%Y %H:%M")
     543            transition_title = TRANSITION_DICT[transition_id]
     544            self.context.messages += '<br />%s - %s' % (timestamp,transition_title)
    532545        self.flash('Form has been saved.')
    533546        return
     
    594607            return
    595608        IWorkflowInfo(self.context).fireTransition('submit')
     609        timestamp = datetime.now().strftime("%d/%m/%Y %H:%M")
     610        transition_title = TRANSITION_DICT['submit']
     611        self.context.messages += '<br />%s - %s' % (timestamp,transition_title)
    596612        self.context.locked = True
    597613        self.flash('Form has been submitted.')
Note: See TracChangeset for help on using the changeset viewer.