#11855 closed enhancement (fixed)
Workflow macro could use name/label attribute in place of action names
Reported by: | Ryan J Ollos | Owned by: | |
---|---|---|---|
Priority: | normal | Milestone: | 1.0.3 |
Component: | ticket system | Version: | |
Severity: | normal | Keywords: | workflow |
Cc: | Branch: | ||
Release Notes: |
Use |
||
API Changes: | |||
Internal Changes: |
Description
It could be nice to use the action name
/label
(#11828) attribute in place of the action name when rendering the workflow graph. The tags/trac-1.0.2/contrib/workflow/opensource-workflow.ini demonstrates that the action names are often not visually appealing and don't represent what the user sees:
The following patch should work well on the trunk after #11828:
-
trac/ticket/default_workflow.py
diff --git a/trac/ticket/default_workflow.py b/trac/ticket/default_workflow.py index 2310f2f..e6d3ee7 100644
a b class WorkflowMacro(WikiMacroBase): 533 533 [state for action in actions.itervalues() 534 534 for state in action['oldstates']] + 535 535 [action['newstate'] for action in actions.itervalues()])) 536 action_labels = [attrs['label'] 537 for name, attrs in actions.items()] 536 538 action_names = actions.keys() 537 539 edges = [] 538 540 for name, action in actions.items(): … … class WorkflowMacro(WikiMacroBase): 545 547 args = args or {} 546 548 width = args.get('width', 800) 547 549 height = args.get('height', 600) 548 graph = {'nodes': states, 'actions': action_ names, 'edges': edges,550 graph = {'nodes': states, 'actions': action_labels, 'edges': edges, 549 551 'width': width, 'height': height} 550 552 graph_id = '%012x' % id(graph) 551 553 req = formatter.req
On 1.0-stable the patch differs slightly:
-
trac/ticket/default_workflow.py
diff --git a/trac/ticket/default_workflow.py b/trac/ticket/default_workflow.py index 8cb0643..e705ab4 100644
a b class WorkflowMacro(WikiMacroBase): 496 496 [state for action in actions.itervalues() 497 497 for state in action['oldstates']] + 498 498 [action['newstate'] for action in actions.itervalues()])) 499 action_labels = [attrs.get('name', name) 500 for name, attrs in actions.items()] 499 501 action_names = actions.keys() 500 502 edges = [] 501 503 for name, action in actions.items(): … … class WorkflowMacro(WikiMacroBase): 508 510 args = args or {} 509 511 width = args.get('width', 800) 510 512 height = args.get('height', 600) 511 graph = {'nodes': states, 'actions': action_ names, 'edges': edges,513 graph = {'nodes': states, 'actions': action_labels, 'edges': edges, 512 514 'width': width, 'height': height} 513 515 graph_id = '%012x' % id(graph) 514 516 req = formatter.req
Attachments (0)
Change History (5)
comment:1 by , 10 years ago
Milestone: | next-stable-1.0.x → 1.0.3 |
---|---|
Release Notes: | modified (diff) |
Resolution: | → fixed |
Status: | new → closed |
comment:2 by , 10 years ago
I have a question about the changes. Do actions.keys()
, actions.values()
and actions.items()
always iterate its entries in the same order?
comment:3 by , 10 years ago
I would be surprised if all three methods do not always iterate in the order that the dictionary items are stored in memory, but I do not have a reference to prove that is the case.
Even prior to the changes the code has assumed that keys
and items
are iterating the entries in the same order: tags/trac-1.0.2/trac/ticket/default_workflow.py@:481,483,485#L465.
follow-up: 5 comment:4 by , 10 years ago
From Python docs:
If
items()
,keys()
,values()
,iteritems()
,iterkeys()
, anditervalues()
are called with no intervening modifications to the dictionary, the lists will directly correspond.
Is this not sufficient?
comment:5 by , 10 years ago
From Python docs:
If
items()
,keys()
,values()
,iteritems()
,iterkeys()
, anditervalues()
are called with no intervening modifications to the dictionary, the lists will directly correspond.Is this not sufficient?
Thanks for the information. I understand the changes have no issues. Sorry for the noise.
Committed to 1.0-stable in [13507]. Merged to trunk in [13508:13509].