Commit 433fdc76 authored by Romain Courteaud's avatar Romain Courteaud

slapos_crm: do not create event if the ticket exists

- drop Base_getSupportRequestInProgress
- drop SupportRequest_getLastEvent
parent d51fc308
portal = context.getPortalObject()
return portal.portal_catalog.getResultValue(
portal_type='Support Request',
title={'query': title, 'key': 'ExactMatch'},
simulation_state=["validated", "submitted", "suspended"],
causality__uid=context.getUid(),
)
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="_reconstructor" module="copy_reg"/>
</klass>
<tuple>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
<global name="object" module="__builtin__"/>
<none/>
</tuple>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>title</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Base_getSupportRequestInProgress</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -65,21 +65,19 @@ for software_installation in software_installation_list: ...@@ -65,21 +65,19 @@ for software_installation in software_installation_list:
return return
notification_message_reference = 'slapos-crm-compute_node_software_installation_state.notification' notification_message_reference = 'slapos-crm-compute_node_software_installation_state.notification'
event = support_request.SupportRequest_getLastEvent(ticket_title) support_request.Ticket_createProjectEvent(
if event is None: ticket_title, 'outgoing', 'Web Message',
support_request.Ticket_createProjectEvent( portal.service_module.slapos_crm_information.getRelativeUrl(),
ticket_title, 'outgoing', 'Web Message', text_content=description,
portal.service_module.slapos_crm_information.getRelativeUrl(), content_type='text/plain',
text_content=description, notification_message=notification_message_reference,
content_type='text/plain', #language=XXX,
notification_message=notification_message_reference, substitution_method_parameter_dict={
#language=XXX, 'compute_node_title':context.getTitle(),
substitution_method_parameter_dict={ 'compute_node_id':reference,
'compute_node_title':context.getTitle(), 'last_contact':last_contact
'compute_node_id':reference, }
'last_contact':last_contact )
}
)
support_request_list.append(support_request) support_request_list.append(support_request)
......
...@@ -76,36 +76,31 @@ if not should_notify: ...@@ -76,36 +76,31 @@ if not should_notify:
context.getTitle(), context.getReference(), last_contact) context.getTitle(), context.getReference(), last_contact)
if should_notify: if should_notify:
support_request = context.Base_getSupportRequestInProgress(
title=node_ticket_title)
if support_request is None: project = context.getFollowUpValue()
project = context.getFollowUpValue() support_request = project.Project_createSupportRequestWithCausality(
support_request = project.Project_createSupportRequestWithCausality( ticket_title,
ticket_title, description,
description, causality=context.getRelativeUrl(),
causality=context.getRelativeUrl(), destination_decision=project.getDestination()
destination_decision=project.getDestination() )
)
if support_request is None: if support_request is None:
return return
event = support_request.SupportRequest_getLastEvent(ticket_title) support_request.Ticket_createProjectEvent(
if event is None: ticket_title, 'outgoing', 'Web Message',
support_request.Ticket_createProjectEvent( portal.service_module.slapos_crm_information.getRelativeUrl(),
ticket_title, 'outgoing', 'Web Message', text_content=description,
portal.service_module.slapos_crm_information.getRelativeUrl(), content_type='text/plain',
text_content=description, notification_message=notification_message_reference,
content_type='text/plain', #language=XXX,
notification_message=notification_message_reference, substitution_method_parameter_dict={
#language=XXX, 'compute_node_title':context.getTitle(),
substitution_method_parameter_dict={ 'compute_node_id':reference,
'compute_node_title':context.getTitle(), 'last_contact':last_contact,
'compute_node_id':reference, 'issue_document_reference': issue_document_reference
'last_contact':last_contact, }
'issue_document_reference': issue_document_reference )
}
)
return support_request return support_request
...@@ -58,19 +58,17 @@ for instance in software_instance_list: ...@@ -58,19 +58,17 @@ for instance in software_instance_list:
if support_request is None: if support_request is None:
return return
event = support_request.SupportRequest_getLastEvent(ticket_title) support_request.Ticket_createProjectEvent(
if event is None: ticket_title, 'outgoing', 'Web Message',
support_request.Ticket_createProjectEvent( portal.service_module.slapos_crm_information.getRelativeUrl(),
ticket_title, 'outgoing', 'Web Message', text_content=description,
portal.service_module.slapos_crm_information.getRelativeUrl(), content_type='text/plain',
text_content=description, notification_message=notification_message_reference,
content_type='text/plain', #language=XXX,
notification_message=notification_message_reference, substitution_method_parameter_dict={
#language=XXX, 'instance_tree_title':context.getTitle(),
substitution_method_parameter_dict={ 'instance': instance.getTitle(),
'instance_tree_title':context.getTitle(), 'error_text': error_message
'instance': instance.getTitle(), }
'error_text': error_message )
}
)
return return
...@@ -3,7 +3,12 @@ project = context ...@@ -3,7 +3,12 @@ project = context
causality_value = portal.restrictedTraverse(causality) causality_value = portal.restrictedTraverse(causality)
if causality_value.Base_getSupportRequestInProgress(title=title) is not None: if portal.portal_catalog.getResultValue(
portal_type='Support Request',
title={'query': title, 'key': 'ExactMatch'},
simulation_state=["validated", "submitted", "suspended"],
causality__uid=causality_value.getUid(),
) is not None:
return return
destination_decision_value = portal.restrictedTraverse(destination_decision) destination_decision_value = portal.restrictedTraverse(destination_decision)
......
portal = context.getPortalObject()
return portal.portal_catalog.getResultValue(
title={'query': title, 'key': 'ExactMatch'},
follow_up__uid=context.getUid(),
portal_type=portal.getPortalEventTypeList(),
sort_on=[('delivery.start_date', 'DESC')])
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="_reconstructor" module="copy_reg"/>
</klass>
<tuple>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
<global name="object" module="__builtin__"/>
<none/>
</tuple>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>title</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>SupportRequest_getLastEvent</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -16,19 +16,17 @@ if document.getSlapState() == "destroy_requested": ...@@ -16,19 +16,17 @@ if document.getSlapState() == "destroy_requested":
""" """
ticket_title = "Instance Tree was destroyed was destroyed by the user" ticket_title = "Instance Tree was destroyed was destroyed by the user"
event = context.SupportRequest_getLastEvent(ticket_title) event = context.Ticket_createProjectEvent(
if event is None: ticket_title, 'outgoing', 'Web Message',
context.Ticket_createProjectEvent( portal.service_module.slapos_crm_information.getRelativeUrl(),
ticket_title, 'outgoing', 'Web Message', text_content=message,
portal.service_module.slapos_crm_information.getRelativeUrl(), content_type='text/plain',
text_content=message, notification_message="slapos-crm-support-request-close-destroyed-notification",
content_type='text/plain', #language=XXX,
notification_message="slapos-crm-support-request-close-destroyed-notification", substitution_method_parameter_dict={
#language=XXX, 'instance_tree_title': document.getTitle()
substitution_method_parameter_dict={ }
'instance_tree_title': document.getTitle() )
}
)
try: try:
context.validate() context.validate()
......
...@@ -113,7 +113,6 @@ def makeTestSlapOSCodingStyleTestCase(tested_business_template): ...@@ -113,7 +113,6 @@ def makeTestSlapOSCodingStyleTestCase(tested_business_template):
'slapos_cloud/SoftwareRelease_getRelatedNetworkList', 'slapos_cloud/SoftwareRelease_getRelatedNetworkList',
'slapos_cloud/SoftwareRelease_getUsableComputeNodeList', 'slapos_cloud/SoftwareRelease_getUsableComputeNodeList',
'slapos_cloud/SoftwareInstance_viewRenameAndRequestDestroyAction', 'slapos_cloud/SoftwareInstance_viewRenameAndRequestDestroyAction',
'slapos_cloud/Base_getSupportRequestInProgress',
'slapos_cloud/SoftwareInstance_checkDuplicationOnInstanceTreeConsistency', 'slapos_cloud/SoftwareInstance_checkDuplicationOnInstanceTreeConsistency',
'slapos_cloud/ComputerNetwork_getRelatedSoftwareReleaseList', 'slapos_cloud/ComputerNetwork_getRelatedSoftwareReleaseList',
'slapos_crm_monitoring/ComputeNode_checkInstanceOnCloseAllocation', 'slapos_crm_monitoring/ComputeNode_checkInstanceOnCloseAllocation',
...@@ -125,7 +124,6 @@ def makeTestSlapOSCodingStyleTestCase(tested_business_template): ...@@ -125,7 +124,6 @@ def makeTestSlapOSCodingStyleTestCase(tested_business_template):
'slapos_crm_monitoring/SupportRequest_getMonitorUrl', 'slapos_crm_monitoring/SupportRequest_getMonitorUrl',
'slapos_crm_monitoring/SupportRequest_recheckMonitoring', 'slapos_crm_monitoring/SupportRequest_recheckMonitoring',
'slapos_crm_monitoring/Event_checkCustomerAsSourceOrDestinationConsistency', 'slapos_crm_monitoring/Event_checkCustomerAsSourceOrDestinationConsistency',
'slapos_crm_monitoring/SupportRequest_getLastEvent',
'slapos_crm_monitoring/Project_createSupportRequestWithCausality', 'slapos_crm_monitoring/Project_createSupportRequestWithCausality',
'slapos_crm/RegularisationRequest_afterClone', 'slapos_crm/RegularisationRequest_afterClone',
'slapos_crm/RegularisationRequest_getResourceItemList', 'slapos_crm/RegularisationRequest_getResourceItemList',
......
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