Commit 2a2c34a7 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_web: Do not allow user change software_type using parameter form

Change software type can be catastrophic, so the parameter form has to restrict update of parameters in order to not allow user make a mistake.

This change is a complete of the commit f65752c5
parent e7547a7c
......@@ -542,13 +542,13 @@
$(to_hide).addClass("hidden-button");
}
this.options = options;
return g.loadSoftwareJSON(g.options.json_url).push(function (json) {
var option_index,
option,
option_selected = options.parameter.softwaretypeindex,
restricted_softwaretype = options.parameter.restricted_softwaretype,
input = g.props.element.querySelector('select.slapos-software-type'),
s_input = g.props.element.querySelector('input.slapos-serialisation-type');
......@@ -580,8 +580,14 @@
if (option_index === option_selected) {
option.selected = "selected";
}
if (restricted_softwaretype === true) {
if (option.value === options.parameter.softwaretype) {
input.appendChild(option);
}
} else {
input.appendChild(option);
}
}
}
}
......
......@@ -236,7 +236,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>950.44887.51427.32153</string> </value>
<value> <string>950.52652.28107.49237</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -254,7 +254,7 @@
</tuple>
<state>
<tuple>
<float>1461811945.72</float>
<float>1461814951.2</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -6,7 +6,8 @@ request = context.REQUEST
option_dict = {
'parameter' : {
'json_url': "%s.json" % context.getUrlString(),
'parameter_hash': base64.b64encode('<?xml version="1.0" encoding="utf-8" ?><instance></instance>')
'parameter_hash': base64.b64encode('<?xml version="1.0" encoding="utf-8" ?><instance></instance>'),
'restricted_softwaretype': False
},
}
......@@ -20,5 +21,6 @@ if context.getPortalType() == "Hosting Subscription":
option_dict['parameter']['softwaretype'] = context.getSourceReference()
if context.getTextContent() is not None:
option_dict['parameter']['parameter_hash'] = base64.b64encode(context.getTextContent())
option_dict['parameter']['restricted_softwaretype'] = True
return json.dumps(option_dict)
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