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>
......@@ -7,22 +7,21 @@ if person is None:
return
if context.getSpecialise() is not None:
return
return
if context.getValidationState() == "validated":
return
state = "started"
shared = False
request_kw = {}
request_kw.update(
software_release=context.getUrlString(),
software_title=context.getTitle() + " %s" % str(context.getUid()),
software_type="RootSoftwareInstance",
software_type=context.getSourceReference(),
instance_xml=context.getTextContent(),
sla_xml="",
shared=shared,
shared=context.getRootSlave(),
state=state,
)
......
......@@ -7,20 +7,10 @@ if REQUEST is not None:
request = context.REQUEST
portal = context.getPortalObject()
##### Starting Hardcoded Information ######
instance_xml = """<?xml version="1.0" encoding="utf-8"?>
<instance>
</instance>
"""
software_type = "RootSoftwareInstance"
#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
trial_configuration = context.TrialRequest_getTrialConfiguration(software_release)
######
software_title = "'CDN ME free trial' for '%s'" % (email)
software_title = trial_configuration["base_software_title"] % (email)
trial_request = portal.portal_catalog.getResultValue(
......@@ -39,19 +29,20 @@ trial_request_list = portal.portal_catalog(
limit=31
)
if len(trial_request_list) >= 30:
if len(trial_request_list) >= 10:
return context.Base_redirect("slapos-Free.Trial.ExceedLimit.Message")
now = DateTime()
trial = context.trial_request_module.newContent(
source_reference="RootSoftwareInstance",
source_reference=trial_configuration["software_type"],
title=software_title,
url_string=url,
text_content=instance_xml,
url_string=trial_configuration["url"],
text_content=trial_configuration["instance_xml"],
start_date=now,
stop_date=now + 21
stop_date=now + 30,
root_slave=trial_configuration["shared"]
)
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