Changeset 6420


Ignore:
Timestamp:
20 Jun 2011, 14:44:37 (14 years ago)
Author:
uli
Message:

Support comments when doing accesscode transitions. These comments will appear in the respective access codes history.

Location:
main/waeup.sirp/trunk/src/waeup/sirp/accesscodes
Files:
2 edited

Legend:

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

    r6418 r6420  
    411411    return code
    412412
    413 def fire_transition(access_code, arg, toward=False):
     413def fire_transition(access_code, arg, toward=False, comment=None):
    414414    """Fire workflow transition for access code.
    415415
     
    424424    transition id as `arg`, otherwise you must give a transition
    425425    target.
     426
     427    If `comment` is specified (default is ``None``) the given string
     428    will be passed along as transition comment. It will appear in the
     429    history of the changed access code. You can use this to place
     430    remarks like for which object the access code was used or similar.
    426431
    427432    :func:`fire_transition` might raise exceptions depending on the
     
    458463    info = IWorkflowInfo(ac)
    459464    if toward:
    460         info.fireTransitionToward(arg)
     465        info.fireTransitionToward(arg, comment=comment)
    461466    else:
    462         info.fireTransition(arg)
     467        info.fireTransition(arg, comment=comment)
    463468    return True
    464469
    465 def invalidate_accesscode(access_code):
     470def invalidate_accesscode(access_code, comment=None):
    466471    """Invalidate AccessCode denoted by string ``access_code``.
    467472
    468473    Fires an appropriate transition to perform the task.
     474
     475    `comment` is a string that will appear in the access code
     476    history.
    469477
    470478    See :func:`fire_transition` for possible exceptions and their
    471479    meanings.
    472480    """
    473     return fire_transition(access_code, 'use')
    474 
    475 def disable_accesscode(access_code):
     481    return fire_transition(access_code, 'use', comment=comment)
     482
     483def disable_accesscode(access_code, comment=None):
    476484    """Disable AccessCode denoted by string ``access_code``.
    477485
    478486    Fires an appropriate transition to perform the task.
     487
     488    `comment` is a string that will appear in the access code
     489    history.
    479490
    480491    See :func:`fire_transition` for possible exceptions and their
    481492    meanings.
    482493    """
    483     return fire_transition(access_code, DISABLED, toward=True)
    484 
    485 def reenable_accesscode(access_code):
     494    return fire_transition(
     495        access_code, DISABLED, toward=True, comment=comment)
     496
     497def reenable_accesscode(access_code, comment=None):
    486498    """Reenable AccessCode denoted by string ``access_code``.
    487499
    488500    Fires an appropriate transition to perform the task.
     501
     502    `comment` is a string that will appear in the access code
     503    history.
    489504
    490505    See :func:`fire_transition` for possible exceptions and their
    491506    meanings.
    492507    """
    493     return fire_transition(access_code, 'reenable')
     508    return fire_transition(access_code, 'reenable', comment=comment)
  • main/waeup.sirp/trunk/src/waeup/sirp/accesscodes/workflow.py

    r6413 r6420  
    119119    msg = '%s - %s (new state: %s)' % (
    120120        timestamp, event.destination.title, event.destination)
     121    if event.comment is not None:
     122        msg = '%s, %s' % (msg, event.comment)
    121123    history = IObjectHistory(obj)
    122124    history.addMessage(msg)
Note: See TracChangeset for help on using the changeset viewer.