0001-workflow-add-a-trace-on-update-carddata-by-wf-action.patch
tests/workflow/test_carddata.py | ||
---|---|---|
634 | 634 |
assert data.data['2'] == 'c' |
635 | 635 |
assert data.data['2_display'] == 'cook' |
636 | 636 |
assert data.data['2_structured'] == {'id': 'c', 'text': 'cook', 'extra': 'plop2'} |
637 |
# check evolutions & tracing |
|
638 |
assert isinstance(data.evolution[0].parts[0], ActionsTracingEvolutionPart) |
|
639 |
assert data.evolution[0].parts[0].actions[0][1:] == ( |
|
640 |
'edit_carddata', # item key |
|
641 |
'edit', # item id |
|
642 |
'st1', # status |
|
643 |
wf.id, # workflow id |
|
644 |
) |
|
637 | 645 | |
638 | 646 |
formdata = formdef.data_class()() |
639 | 647 |
formdata.data = {'0': '1', '1': 'b'} |
wcs/backoffice/management.py | ||
---|---|---|
44 | 44 |
from wcs.forms.common import FormStatusPage |
45 | 45 |
from wcs.roles import logged_users_role |
46 | 46 |
from wcs.variables import LazyFieldVar, LazyList |
47 |
from wcs.workflows import ActionsTracingEvolutionPart, WorkflowStatusItem, item_classes, template_on_formdata |
|
47 |
from wcs.workflows import ( |
|
48 |
ActionsTracingEvolutionPart, |
|
49 |
Workflow, |
|
50 |
WorkflowStatusItem, |
|
51 |
item_classes, |
|
52 |
template_on_formdata, |
|
53 |
) |
|
48 | 54 | |
49 | 55 |
from ..qommon import _, errors, ezt, force_str, get_cfg, misc, ngettext, ods, pgettext_lazy, template |
50 | 56 |
from ..qommon.afterjobs import AfterJob |
... | ... | |
3747 | 3753 |
if part.actions and part != last_event_line: |
3748 | 3754 |
last_event_line = part |
3749 | 3755 |
r += htmltext('<li><span class="event">%s</span></li>') % part.get_event_label() |
3750 |
for action_ts, action_key, action_id in part.actions: |
|
3756 |
for action_parts in part.actions: |
|
3757 |
external_status_id, external_wf_id = None, None |
|
3758 |
if len(action_parts) == 5: |
|
3759 |
( |
|
3760 |
action_ts, |
|
3761 |
action_key, |
|
3762 |
action_id, |
|
3763 |
external_status_id, |
|
3764 |
external_wf_id, |
|
3765 |
) = action_parts |
|
3766 |
else: |
|
3767 |
action_ts, action_key, action_id = action_parts[:3] |
|
3768 |
external_wf = None |
|
3769 |
if external_wf_id: |
|
3770 |
external_wf = Workflow.get(external_wf_id, ignore_errors=True) |
|
3751 | 3771 |
action_label = action_classes.get(action_key, action_key) |
3752 | 3772 |
try: |
3753 | 3773 |
url = '%sitems/%s/' % ( |
3754 |
part.get_base_url(self.filled.formdef.workflow, wf_status), |
|
3774 |
part.get_base_url( |
|
3775 |
external_wf or self.filled.formdef.workflow, |
|
3776 |
external_status_id or wf_status, |
|
3777 |
), |
|
3755 | 3778 |
action_id, |
3756 | 3779 |
) |
3757 | 3780 |
except KeyError: |
... | ... | |
3763 | 3786 |
url, |
3764 | 3787 |
action_label, |
3765 | 3788 |
) |
3766 |
real_action = part.get_real_action(self.filled.formdef.workflow, wf_status, action_id) |
|
3789 |
if external_wf: |
|
3790 |
r += htmltext(' <span class="tracing-details">(%s)</span>') % _( |
|
3791 |
'external workflow' |
|
3792 |
) |
|
3793 |
real_action = part.get_real_action( |
|
3794 |
external_wf or self.filled.formdef.workflow, |
|
3795 |
external_status_id or wf_status, |
|
3796 |
action_id, |
|
3797 |
) |
|
3767 | 3798 |
if real_action: |
3768 | 3799 |
details = real_action.get_inspect_details() |
3769 | 3800 |
if details: |
wcs/wf/edit_carddata.py | ||
---|---|---|
14 | 14 |
# You should have received a copy of the GNU General Public License |
15 | 15 |
# along with this program; if not, see <http://www.gnu.org/licenses/>. |
16 | 16 | |
17 |
import datetime |
|
18 |
import time |
|
19 | ||
17 | 20 |
from quixote import get_publisher |
18 | 21 | |
22 |
from wcs.formdata import Evolution |
|
19 | 23 |
from wcs.qommon import _ |
20 | 24 |
from wcs.wf.create_carddata import CreateCarddataWorkflowStatusItem |
21 | 25 |
from wcs.wf.external_workflow import ExternalWorkflowGlobalAction |
22 |
from wcs.workflows import register_item_class |
|
26 |
from wcs.workflows import ActionsTracingEvolutionPart, register_item_class
|
|
23 | 27 | |
24 | 28 | |
25 | 29 |
class EditCarddataWorkflowStatusItem(CreateCarddataWorkflowStatusItem, ExternalWorkflowGlobalAction): |
... | ... | |
51 | 55 |
for target_data in self.iter_target_datas(formdata, carddef): |
52 | 56 |
self.apply_mappings(dest=target_data, src=formdata) |
53 | 57 |
with get_publisher().substitutions.freeze(): |
58 |
# store an ActionsTracingEvolutionPart with a link to current workflow & action |
|
59 |
evo = Evolution() |
|
60 |
evo.time = time.localtime() |
|
61 |
evo.status = target_data.status |
|
62 |
performed_action = ( |
|
63 |
datetime.datetime.now(), |
|
64 |
self.key, |
|
65 |
self.id, |
|
66 |
self.parent.id, |
|
67 |
self.parent.parent.id, |
|
68 |
) |
|
69 |
evo.add_part(ActionsTracingEvolutionPart('workflow-edited', [performed_action])) |
|
70 |
target_data.evolution.append(evo) |
|
54 | 71 |
target_data.store() |
55 | 72 | |
56 | 73 |
# update local object as it may have modified itself |
wcs/workflows.py | ||
---|---|---|
419 | 419 |
'json-import-created': _('Created (by JSON import)'), |
420 | 420 |
'timeout-jump': _('Timeout jump'), |
421 | 421 |
'workflow-created': _('Created (by workflow action)'), |
422 |
'workflow-edited': _('Edited (by workflow action)'), |
|
422 | 423 |
'workflow-form-submit': _('Action in workflow form'), |
423 | 424 |
}.get(self.event, self.event) |
424 | 425 | |
425 |
- |