Changeset 6318


Ignore:
Timestamp:
10 Jun 2011, 01:51:30 (13 years ago)
Author:
uli
Message:

Add subscriber that replaces the redundant code from browser.py.

File:
1 edited

Legend:

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

    r6316 r6318  
    22"""
    33import grok
     4from datetime import datetime
    45from hurry.workflow.workflow import (
    56    Transition, Workflow, WorkflowVersions, WorkflowInfo, WorkflowState,
     
    78from hurry.workflow.interfaces import (
    89    IWorkflow, IWorkflowState, IWorkflowInfo, IWorkflowVersions,
    9     InvalidTransitionError)
     10    InvalidTransitionError, IWorkflowTransitionEvent)
    1011from waeup.sirp.applicants.interfaces import IApplicantBaseData
    1112
     
    153154    grok.context(IApplicantBaseData)
    154155    grok.provides(IWorkflowInfo)
     156
     157
     158@grok.subscribe(IApplicantBaseData, IWorkflowTransitionEvent)
     159def handle_applicant_transition_event(obj, event):
     160    """Append message to applicant when transition happened.
     161    """
     162    timestamp = datetime.now().strftime("%d/%m/%Y %H:%M:%S")
     163    comment = event.comment or '(no comment)'
     164    # XXX: `messages` is meta data which shouldn't really be part of
     165    #      the Applicant class. Furthermore we should not store HTML
     166    #      code but simple messages. This has to be cleaned up
     167    #      further. For now we replace the redundant code in browser
     168    #      mod.  As we're here: one could use permissions and similar
     169    #      to finetune transitions instead of doing that manually in
     170    #      UI stuff.
     171    msg = '%s - %s to %s: %s: %s' % (
     172        timestamp, event.source, event.destination, event.transition.title,
     173        comment)
     174    msgs = getattr(obj, 'messages', None)
     175    if msgs != '':
     176        msgs += '<br />'
     177    obj.messages += msg
     178    return
Note: See TracChangeset for help on using the changeset viewer.