Add actions to workflow preview
Signed-off-by: Roberto Rosario <roberto.rosario@mayan-edms.com>
This commit is contained in:
@@ -100,6 +100,7 @@ class Workflow(models.Model):
|
||||
}, format='png'
|
||||
)
|
||||
|
||||
action_cache = {}
|
||||
state_cache = {}
|
||||
transition_cache = []
|
||||
|
||||
@@ -111,6 +112,14 @@ class Workflow(models.Model):
|
||||
'connections': {'origin': 0, 'destination': 0}
|
||||
}
|
||||
|
||||
for action in state.actions.all():
|
||||
action_cache['a{}'.format(action.pk)] = {
|
||||
'name': 'a{}'.format(action.pk),
|
||||
'label': action.label,
|
||||
'state': 's{}'.format(state.pk),
|
||||
'when': action.when,
|
||||
}
|
||||
|
||||
for transition in self.transitions.all():
|
||||
transition_cache.append(
|
||||
{
|
||||
@@ -133,6 +142,25 @@ class Workflow(models.Model):
|
||||
for transition in transition_cache:
|
||||
diagram.edge(**transition)
|
||||
|
||||
for key, value in action_cache.items():
|
||||
kwargs = {
|
||||
'name': value['name'],
|
||||
'label': value['label'],
|
||||
'shape': 'box',
|
||||
}
|
||||
diagram.node(**kwargs)
|
||||
diagram.edge(
|
||||
**{
|
||||
'head_name': '{}'.format(value['name']),
|
||||
'tail_name': '{}'.format(value['state']),
|
||||
'label': 'On entry' if value['when'] == WORKFLOW_ACTION_ON_ENTRY else 'On exit',
|
||||
'arrowhead': 'dot',
|
||||
'dir': 'both',
|
||||
'arrowtail': 'dot',
|
||||
'style': 'dashed',
|
||||
}
|
||||
)
|
||||
|
||||
return diagram.pipe()
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
|
||||
Reference in New Issue
Block a user