Commit 79b1be21 authored by Romain Courteaud's avatar Romain Courteaud

slapos_crm: use notification message title instead of the ticket title

parent 0c8fd7f1
...@@ -23,7 +23,6 @@ else: ...@@ -23,7 +23,6 @@ else:
event_kw = { event_kw = {
'portal_type': portal_type, 'portal_type': portal_type,
'title': title,
'resource': resource, 'resource': resource,
'source': source_relative_url, 'source': source_relative_url,
'source_section': source_section_relative_url, 'source_section': source_section_relative_url,
...@@ -48,6 +47,11 @@ if notification_message: ...@@ -48,6 +47,11 @@ if notification_message:
substitution_method_parameter_dict=substitution_method_parameter_dict substitution_method_parameter_dict=substitution_method_parameter_dict
) )
# Prefer using the notification message title
# as it will be correctly translated
if not event.hasTitle():
event.edit(title=title)
if not keep_draft: if not keep_draft:
if direction == 'incoming': if direction == 'incoming':
# Support event_workflow and event_simulation_workflow # Support event_workflow and event_simulation_workflow
......
...@@ -633,7 +633,12 @@ class TestSlapOSCrmMonitoringCheckComputeNodeState(SlapOSTestCaseMixinWithAbort) ...@@ -633,7 +633,12 @@ class TestSlapOSCrmMonitoringCheckComputeNodeState(SlapOSTestCaseMixinWithAbort)
self.assertEqual(len(event_list), 1) self.assertEqual(len(event_list), 1)
event = event_list[0] event = event_list[0]
self.assertEqual(event.getTitle(), ticket.getTitle()) self.assertEqual(
event.getTitle(),
self.portal.restrictedTraverse(
self.portal.REQUEST['test_ComputeNode_checkSoftwareInstallationState_notify']
).getTitle()
)
self.assertIn(compute_node.getReference(), event.getTextContent()) self.assertIn(compute_node.getReference(), event.getTextContent())
self.assertEqual(event.getFollowUp(), ticket.getRelativeUrl()) self.assertEqual(event.getFollowUp(), ticket.getRelativeUrl())
self.assertEqual(event.getSourceProject(), compute_node.getFollowUp()) self.assertEqual(event.getSourceProject(), compute_node.getFollowUp())
...@@ -665,7 +670,12 @@ class TestSlapOSCrmMonitoringCheckComputeNodeState(SlapOSTestCaseMixinWithAbort) ...@@ -665,7 +670,12 @@ class TestSlapOSCrmMonitoringCheckComputeNodeState(SlapOSTestCaseMixinWithAbort)
self.assertEqual(len(event_list), 1) self.assertEqual(len(event_list), 1)
event = event_list[0] event = event_list[0]
self.assertEqual(event.getTitle(), ticket.getTitle()) self.assertEqual(
event.getTitle(),
self.portal.restrictedTraverse(
self.portal.REQUEST['test_ComputeNode_checkSoftwareInstallationState_notify']
).getTitle()
)
self.assertIn(compute_node.getReference(), event.getTextContent()) self.assertIn(compute_node.getReference(), event.getTextContent())
self.assertEqual(event.getFollowUp(), ticket.getRelativeUrl()) self.assertEqual(event.getFollowUp(), ticket.getRelativeUrl())
self.assertEqual(event.getSourceProject(), compute_node.getFollowUp()) self.assertEqual(event.getSourceProject(), compute_node.getFollowUp())
...@@ -708,7 +718,12 @@ class TestSlapOSCrmMonitoringCheckComputeNodeState(SlapOSTestCaseMixinWithAbort) ...@@ -708,7 +718,12 @@ class TestSlapOSCrmMonitoringCheckComputeNodeState(SlapOSTestCaseMixinWithAbort)
self.assertEqual(len(event_list), 1) self.assertEqual(len(event_list), 1)
event = event_list[0] event = event_list[0]
self.assertEqual(event.getTitle(), ticket.getTitle()) self.assertEqual(
event.getTitle(),
self.portal.restrictedTraverse(
self.portal.REQUEST['test_ComputeNode_checkSoftwareInstallationState_notify']
).getTitle()
)
self.assertIn(compute_node.getReference(), event.getTextContent()) self.assertIn(compute_node.getReference(), event.getTextContent())
self.assertEqual(event.getFollowUp(), ticket.getRelativeUrl()) self.assertEqual(event.getFollowUp(), ticket.getRelativeUrl())
self.assertEqual(event.getSourceProject(), compute_node.getFollowUp()) self.assertEqual(event.getSourceProject(), compute_node.getFollowUp())
...@@ -752,7 +767,12 @@ class TestSlapOSCrmMonitoringCheckComputeNodeState(SlapOSTestCaseMixinWithAbort) ...@@ -752,7 +767,12 @@ class TestSlapOSCrmMonitoringCheckComputeNodeState(SlapOSTestCaseMixinWithAbort)
self.assertEqual(len(event_list), 1) self.assertEqual(len(event_list), 1)
event = event_list[0] event = event_list[0]
self.assertEqual(event.getTitle(), ticket.getTitle()) self.assertEqual(
event.getTitle(),
self.portal.restrictedTraverse(
self.portal.REQUEST['test_ComputeNode_checkState_stalled_instance']
).getTitle()
)
self.assertIn(compute_node.getReference(), event.getTextContent()) self.assertIn(compute_node.getReference(), event.getTextContent())
self.assertEqual(event.getFollowUp(), ticket.getRelativeUrl()) self.assertEqual(event.getFollowUp(), ticket.getRelativeUrl())
self.assertEqual(event.getSourceProject(), compute_node.getFollowUp()) self.assertEqual(event.getSourceProject(), compute_node.getFollowUp())
...@@ -845,7 +865,12 @@ class TestSlapOSCrmMonitoringCheckComputeNodeSoftwareInstallation(SlapOSTestCase ...@@ -845,7 +865,12 @@ class TestSlapOSCrmMonitoringCheckComputeNodeSoftwareInstallation(SlapOSTestCase
self.assertEqual(len(event_list), 1) self.assertEqual(len(event_list), 1)
event = event_list[0] event = event_list[0]
self.assertEqual(event.getTitle(), ticket.getTitle()) self.assertEqual(
event.getTitle(),
self.portal.restrictedTraverse(
self.portal.REQUEST['test_ComputeNode_checkState_notify']
).getTitle()
)
self.assertIn(compute_node.getReference(), event.getTextContent()) self.assertIn(compute_node.getReference(), event.getTextContent())
self.assertEqual(event.getFollowUp(), ticket.getRelativeUrl()) self.assertEqual(event.getFollowUp(), ticket.getRelativeUrl())
self.assertEqual(event.getSourceProject(), compute_node.getFollowUp()) self.assertEqual(event.getSourceProject(), compute_node.getFollowUp())
...@@ -889,7 +914,12 @@ class TestSlapOSCrmMonitoringCheckComputeNodeSoftwareInstallation(SlapOSTestCase ...@@ -889,7 +914,12 @@ class TestSlapOSCrmMonitoringCheckComputeNodeSoftwareInstallation(SlapOSTestCase
self.assertEqual(len(event_list), 1) self.assertEqual(len(event_list), 1)
event = event_list[0] event = event_list[0]
self.assertEqual(event.getTitle(), ticket.getTitle()) self.assertEqual(
event.getTitle(),
self.portal.restrictedTraverse(
self.portal.REQUEST['test_ComputeNode_checkState_empty_cache_notify']
).getTitle()
)
self.assertIn(compute_node.getReference(), event.getTextContent()) self.assertIn(compute_node.getReference(), event.getTextContent())
self.assertEqual(event.getFollowUp(), ticket.getRelativeUrl()) self.assertEqual(event.getFollowUp(), ticket.getRelativeUrl())
self.assertEqual(event.getSourceProject(), compute_node.getFollowUp()) self.assertEqual(event.getSourceProject(), compute_node.getFollowUp())
...@@ -961,7 +991,12 @@ class TestSlapOSCrmMonitoringCheckComputeNodeSoftwareInstallation(SlapOSTestCase ...@@ -961,7 +991,12 @@ class TestSlapOSCrmMonitoringCheckComputeNodeSoftwareInstallation(SlapOSTestCase
self.assertEqual(len(event_list), 1) self.assertEqual(len(event_list), 1)
event = event_list[0] event = event_list[0]
self.assertEqual(event.getTitle(), ticket.getTitle()) self.assertEqual(
event.getTitle(),
self.portal.restrictedTraverse(
self.portal.REQUEST['test_ComputeNode_checkState_stalled_instance']
).getTitle()
)
self.assertIn(compute_node.getReference(), event.getTextContent()) self.assertIn(compute_node.getReference(), event.getTextContent())
self.assertEqual(event.getFollowUp(), ticket.getRelativeUrl()) self.assertEqual(event.getFollowUp(), ticket.getRelativeUrl())
self.assertEqual(event.getSourceProject(), compute_node.getFollowUp()) self.assertEqual(event.getSourceProject(), compute_node.getFollowUp())
...@@ -1089,7 +1124,12 @@ class TestSlapOSCrmMonitoringCheckInstanceInError(SlapOSTestCaseMixinWithAbort): ...@@ -1089,7 +1124,12 @@ class TestSlapOSCrmMonitoringCheckInstanceInError(SlapOSTestCaseMixinWithAbort):
self.assertEqual(len(event_list), 1) self.assertEqual(len(event_list), 1)
event = event_list[0] event = event_list[0]
self.assertEqual(event.getTitle(), ticket.getTitle()) self.assertEqual(
event.getTitle(),
self.portal.restrictedTraverse(
self.portal.REQUEST['test_InstanceTree_checkSoftwareInstanceState_notify']
).getTitle()
)
self.assertIn(instance_tree.getReference(), event.getTextContent()) self.assertIn(instance_tree.getReference(), event.getTextContent())
self.assertEqual(event.getFollowUp(), ticket.getRelativeUrl()) self.assertEqual(event.getFollowUp(), ticket.getRelativeUrl())
self.assertEqual(event.getSourceProject(), instance_tree.getFollowUp()) self.assertEqual(event.getSourceProject(), instance_tree.getFollowUp())
...@@ -1162,7 +1202,12 @@ class TestSlapOSCrmMonitoringCheckInstanceInError(SlapOSTestCaseMixinWithAbort): ...@@ -1162,7 +1202,12 @@ class TestSlapOSCrmMonitoringCheckInstanceInError(SlapOSTestCaseMixinWithAbort):
self.assertEqual(len(event_list), 1) self.assertEqual(len(event_list), 1)
event = event_list[0] event = event_list[0]
self.assertEqual(event.getTitle(), ticket.getTitle()) self.assertEqual(
event.getTitle(),
self.portal.restrictedTraverse(
self.portal.REQUEST['test_InstanceTree_checkSoftwareInstanceState_notify']
).getTitle()
)
self.assertIn(instance_tree.getReference(), event.getTextContent()) self.assertIn(instance_tree.getReference(), event.getTextContent())
self.assertEqual(event.getFollowUp(), ticket.getRelativeUrl()) self.assertEqual(event.getFollowUp(), ticket.getRelativeUrl())
self.assertEqual(event.getSourceProject(), instance_tree.getFollowUp()) self.assertEqual(event.getSourceProject(), instance_tree.getFollowUp())
...@@ -1340,7 +1385,12 @@ class TestSlaposCrmUpdateSupportRequestState(SlapOSTestCaseMixinWithAbort): ...@@ -1340,7 +1385,12 @@ class TestSlaposCrmUpdateSupportRequestState(SlapOSTestCaseMixinWithAbort):
self.assertEqual(len(event_list), 1) self.assertEqual(len(event_list), 1)
event = event_list[0] event = event_list[0]
self.assertEqual(event.getTitle(), "Instance Tree was destroyed was destroyed by the user") self.assertEqual(
event.getTitle(),
self.portal.restrictedTraverse(
self.portal.REQUEST['test_SupportRequest_updateMonitoringState_notify']
).getTitle()
)
self.assertIn(instance_tree.getReference(), event.getTextContent()) self.assertIn(instance_tree.getReference(), event.getTextContent())
self.assertEqual(event.getFollowUp(), ticket.getRelativeUrl()) self.assertEqual(event.getFollowUp(), ticket.getRelativeUrl())
self.assertEqual(event.getSourceProject(), instance_tree.getFollowUp()) self.assertEqual(event.getSourceProject(), instance_tree.getFollowUp())
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment