Commit 737028ad authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_crm: Use aggregate instead source_project to aggregate computers and Hosting Subscriptions

parent 4675c289
......@@ -5,4 +5,7 @@
<portal_type id="Regularisation Request Module">
<item>business_application</item>
</portal_type>
<portal_type id="Support Request">
<item>aggregate</item>
</portal_type>
</base_category_list>
\ No newline at end of file
from DateTime import DateTime
portal = context.getPortalObject()
source_project_value = portal.restrictedTraverse(source_relative_url)
if source_project_value.getPortalType() == "Computer":
destination_decision = source_project_value.getSourceAdministration()
elif source_project_value.getPortalType() == "Software Instance":
destination_decision = source_project_value.getSpecialiseValue().getDestinationSection()
elif source_project_value.getPortalType() == "Hosting Subscription":
destination_decision = source_project_value.getDestinationSection()
elif source_project_value.getPortalType() == "Software Installation":
destination_decision = source_project_value.getDestinationSection()
aggregate_value = portal.restrictedTraverse(source_relative_url)
if aggregate_value.getPortalType() == "Computer":
destination_decision = aggregate_value.getSourceAdministration()
elif aggregate_value.getPortalType() == "Software Instance":
destination_decision = aggregate_value.getSpecialiseValue().getDestinationSection()
elif aggregate_value.getPortalType() == "Hosting Subscription":
destination_decision = aggregate_value.getDestinationSection()
elif aggregate_value.getPortalType() == "Software Installation":
destination_decision = aggregate_value.getDestinationSection()
else:
destination_decision = None
......@@ -22,7 +22,7 @@ support_request_in_progress = portal.portal_catalog.getResultValue(
portal_type = 'Support Request',
title = title,
simulation_state = ["validated", "submitted", "suspended"],
source_project_uid = source_project_value.getUid(),
aggregate_uid = aggregate_value.getUid(),
)
if support_request_in_progress is not None:
......@@ -33,7 +33,7 @@ support_request_in_progress = context.REQUEST.get("support_request_in_progress",
if support_request_in_progress is not None:
support_request = portal.restrictedTraverse(support_request_in_progress, None)
if support_request and support_request.getTitle() == title and \
support_request.getSourceProjectUid() == source_project_value.getUid():
support_request.getAggregatetUid() == aggregate_value.getUid():
return portal.restrictedTraverse(support_request_in_progress)
resource = portal.service_module.\
......@@ -48,7 +48,7 @@ support_request.edit(
description = description,
start_date = DateTime(),
destination_decision=destination_decision,
source_project_value = source_project_value,
aggregate_value = aggregate_value,
resource=resource
)
support_request.validate()
......
......@@ -2168,7 +2168,7 @@ class TestSlapOSComputer_notifyWrongAllocationScope(testSlapOSMixin):
portal_type = 'Support Request',
title = request_title,
simulation_state = 'suspended',
source_project_uid = computer.getUid()
aggregate_uid = computer.getUid()
)
return support_request
......@@ -2659,7 +2659,7 @@ class TestSlapOSGenerateSupportRequestForSlapOS(testSlapOSMixin):
self.computer.getSourceAdministration())
self.assertEquals(support_request.getTitle(), title)
self.assertEquals(support_request.getDescription(), title)
self.assertEquals(support_request.getSourceProjectValue(),
self.assertEquals(support_request.getAggregateValue(),
self.computer)
def test_software_instance_Base_generateSupportRequestForSlapOS(self):
......@@ -2685,7 +2685,7 @@ class TestSlapOSGenerateSupportRequestForSlapOS(testSlapOSMixin):
hosting_subscription.getDestinationSection())
self.assertEquals(support_request.getTitle(), title)
self.assertEquals(support_request.getDescription(), title)
self.assertEquals(support_request.getSourceProjectValue(),
self.assertEquals(support_request.getAggregateValue(),
instance)
def test_hosting_subscription_Base_generateSupportRequestForSlapOS(self):
......@@ -2709,7 +2709,7 @@ class TestSlapOSGenerateSupportRequestForSlapOS(testSlapOSMixin):
self.assertEquals(support_request.getTitle(), title)
self.assertEquals(support_request.getDescription(), title)
self.assertEquals(support_request.getSourceProjectValue(),
self.assertEquals(support_request.getAggregateValue(),
hosting_subscription)
def test_software_installation_Base_generateSupportRequestForSlapOS(self):
......@@ -2733,7 +2733,7 @@ class TestSlapOSGenerateSupportRequestForSlapOS(testSlapOSMixin):
self.assertEquals(support_request.getTitle(), title)
self.assertEquals(support_request.getDescription(), title)
self.assertEquals(support_request.getSourceProjectValue(),
self.assertEquals(support_request.getAggregateValue(),
software_installation)
......@@ -2858,7 +2858,7 @@ class TestSlapOSComputer_CheckState(testSlapOSMixin):
portal_type = 'Support Request',
title = request_title,
simulation_state = 'validated',
source_project_uid = computer_uid
aggregate_uid = computer_uid
)
return support_request
......@@ -3046,7 +3046,7 @@ class TestSlapOSHostingSubscription_createSupportRequestEvent(testSlapOSMixin):
support_request = self.portal.portal_catalog.getResultValue(
portal_type = 'Support Request',
simulation_state = "validated",
source_project_uid = hosting_suscription_uid
aggregate_uid = hosting_suscription_uid
)
return support_request
......@@ -3433,7 +3433,7 @@ class TestSupportRequestTrySendNotificationMessage(testSlapOSMixin):
support_request = self.portal.support_request_module.newContent(\
title=title, description=title,
destination_decision=self.computer.getSourceAdministration(),
source_project_value=self.computer.getRelativeUrl())
aggregate_value=self.computer.getRelativeUrl())
support_request.validate()
self.tic()
......@@ -3484,7 +3484,7 @@ class TestSupportRequestTrySendNotificationMessage(testSlapOSMixin):
another_support_request = self.portal.support_request_module.newContent(\
title=title, description=title,
destination_decision=self.computer.getSourceAdministration(),
source_project_value=self.computer.getRelativeUrl())
aggregate_value=self.computer.getRelativeUrl())
another_support_request.validate()
self.tic()
......
Regularisation Request Module | business_application
Regularisation Request | specialise
\ No newline at end of file
Regularisation Request | specialise
Support Request | aggregate
\ No newline at end of file
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