--- a/src/pyams_content/shared/common/zmi/__init__.py Wed Oct 04 12:03:35 2017 +0200
+++ b/src/pyams_content/shared/common/zmi/__init__.py Wed Oct 04 12:03:59 2017 +0200
@@ -294,19 +294,24 @@
# store new version
translate = self.request.localizer.translate
workflow = get_utility(IWorkflow, name=new_content.workflow_name)
- sequence = get_utility(ISequentialIntIds, name=new_content.sequence_name)
IWorkflowVersions(new_content).add_version(new_version, workflow.initial_state)
+ # update new version history
+ source_state = IWorkflowState(self.context)
+ state = IWorkflowState(new_version)
+ state.history.clear()
history = WorkflowHistoryItem(date=datetime.utcnow(),
- source_state=translate(workflow.states.getTerm(IWorkflowState(
- self.context).state).title),
- transition=translate(_("Duplicate content ({oid})")).format(
- oid=sequence.get_short_oid(ISequentialIdInfo(content).oid,
- content.sequence_prefix)),
- target_state=translate(workflow.states.getTerm(workflow.initial_state).title),
+ principal=self.request.principal.id,
+ comment=translate(_("Clone created from version {source} of {oid} (in « {"
+ "state} » state)")).format(
+ source=source_state.version_id,
+ oid=ISequentialIdInfo(self.context).get_short_oid(),
+ state=translate(IWorkflow(self.context).get_state_label(source_state.state)))
+ )
+ state.history.append(history)
+ history = WorkflowHistoryItem(date=datetime.utcnow(),
+ target_state=workflow.initial_state,
principal=self.request.principal.id,
comment=data.get('comment'))
- state = IWorkflowState(new_version)
- state.history.clear()
state.history.append(history)
return new_version