Commit ec5475e3 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_trial: Use Configuration script to load the Free Trial Options.

parent 246d37c8
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<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>software_release</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>TrialRequest_getTrialConfiguration</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -13,16 +13,15 @@ if context.getValidationState() == "validated": ...@@ -13,16 +13,15 @@ if context.getValidationState() == "validated":
return return
state = "started" state = "started"
shared = False
request_kw = {} request_kw = {}
request_kw.update( request_kw.update(
software_release=context.getUrlString(), software_release=context.getUrlString(),
software_title=context.getTitle() + " %s" % str(context.getUid()), software_title=context.getTitle() + " %s" % str(context.getUid()),
software_type="RootSoftwareInstance", software_type=context.getSourceReference(),
instance_xml=context.getTextContent(), instance_xml=context.getTextContent(),
sla_xml="", sla_xml="",
shared=shared, shared=context.getRootSlave(),
state=state, state=state,
) )
......
...@@ -7,20 +7,10 @@ if REQUEST is not None: ...@@ -7,20 +7,10 @@ if REQUEST is not None:
request = context.REQUEST request = context.REQUEST
portal = context.getPortalObject() portal = context.getPortalObject()
##### Starting Hardcoded Information ######
instance_xml = """<?xml version="1.0" encoding="utf-8"?>
<instance>
</instance>
"""
software_type = "RootSoftwareInstance" trial_configuration = context.TrialRequest_getTrialConfiguration(software_release)
#url = 'http://git.erp5.org/gitweb/slapos.git/blob_plain/refs/heads/request.product:/software/cdn-me/software.cfg'
url = "https://lab.node.vifib.com/nexedi/slapos/raw/1.0.21/software/cdn-me/software.cfg"
shared = True
###### software_title = trial_configuration["base_software_title"] % (email)
software_title = "'CDN ME free trial' for '%s'" % (email)
trial_request = portal.portal_catalog.getResultValue( trial_request = portal.portal_catalog.getResultValue(
...@@ -39,19 +29,20 @@ trial_request_list = portal.portal_catalog( ...@@ -39,19 +29,20 @@ trial_request_list = portal.portal_catalog(
limit=31 limit=31
) )
if len(trial_request_list) >= 30: if len(trial_request_list) >= 10:
return context.Base_redirect("slapos-Free.Trial.ExceedLimit.Message") return context.Base_redirect("slapos-Free.Trial.ExceedLimit.Message")
now = DateTime() now = DateTime()
trial = context.trial_request_module.newContent( trial = context.trial_request_module.newContent(
source_reference="RootSoftwareInstance", source_reference=trial_configuration["software_type"],
title=software_title, title=software_title,
url_string=url, url_string=trial_configuration["url"],
text_content=instance_xml, text_content=trial_configuration["instance_xml"],
start_date=now, start_date=now,
stop_date=now + 21 stop_date=now + 30,
root_slave=trial_configuration["shared"]
) )
trial.setDefaultEmailText(email) trial.setDefaultEmailText(email)
......
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