Commit 0d1b6788 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_subscription_request: Ensure you are getting the right free trial user

parent a4421a13
from DateTime import DateTime
portal = context.getPortalObject() portal = context.getPortalObject()
person = portal.portal_catalog.getResultValue( erp5_login = portal.portal_catalog.getResultValue(
portal_type="Person", portal_type="ERP5 Login",
reference="free_trial_user") reference="free_trial_user",
validation_state="validated")
if erp5_login is None:
return
person = erp5_login.getParentValue()
if context.getStopDate() >= DateTime(): if context.getStopDate() >= DateTime():
return return
...@@ -16,7 +21,7 @@ if context.getSpecialise() is None: ...@@ -16,7 +21,7 @@ if context.getSpecialise() is None:
if context.getValidationState() != "validated": if context.getValidationState() != "validated":
return return
state = "destroyed" state = 'destroyed'
hosting_subscription = context.getSpecialiseValue() hosting_subscription = context.getSpecialiseValue()
...@@ -33,6 +38,8 @@ request_kw.update( ...@@ -33,6 +38,8 @@ request_kw.update(
person.requestSoftwareInstance(**request_kw) person.requestSoftwareInstance(**request_kw)
assert hosting_subscription.getSlapState() == "destroy_requested",\
"Hosting Subscription not destroyed!!"
connection_dict = hosting_subscription.getPredecessorValue().getConnectionXmlAsDict() connection_dict = hosting_subscription.getPredecessorValue().getConnectionXmlAsDict()
......
from DateTime import DateTime
from Products.ERP5Type.DateUtils import addToDate
portal = context.getPortalObject() portal = context.getPortalObject()
erp5_login = portal.portal_catalog.getResultValue(
portal_type="ERP5 Login",
reference="free_trial_user",
validation_state="validated")
person = portal.portal_catalog.getResultValue( if erp5_login is None:
portal_type="Person",
reference="free_trial_user")
if person is None:
return "Free Trial Person not Found" return "Free Trial Person not Found"
person = erp5_login.getParentValue()
connection_key_list = context.getSubjectList() connection_key_list = context.getSubjectList()
instance = context.getAggregateValue() instance = context.getAggregateValue()
......
portal = context.getPortalObject() portal = context.getPortalObject()
person = portal.portal_catalog.getResultValue( erp5_login = portal.portal_catalog.getResultValue(
portal_type="Person", portal_type="ERP5 Login",
reference="free_trial_user") reference="free_trial_user",
validation_state="validated")
if person is None: if erp5_login is None:
return return
person = erp5_login.getParentValue()
if context.getSpecialise() is not None: if context.getSpecialise() is not None:
return return
if context.getValidationState() == "validated": if context.getValidationState() == "validated":
return return
if context.getUrlString() is None:
# Nothing to request here
return
state = "started" state = "started"
request_kw = {} request_kw = {}
...@@ -20,8 +27,8 @@ request_kw.update( ...@@ -20,8 +27,8 @@ request_kw.update(
software_title=context.getTitle() + " %s" % str(context.getUid()), software_title=context.getTitle() + " %s" % str(context.getUid()),
software_type=context.getSourceReference(), software_type=context.getSourceReference(),
instance_xml=context.getTextContent(), instance_xml=context.getTextContent(),
sla_xml="", sla_xml=context.getSlaXml(""),
shared=context.getRootSlave(), shared=context.getRootSlave(False),
state=state, state=state,
) )
......
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