Commit c892c53d authored by Romain Courteaud's avatar Romain Courteaud

slapos_panel: improve software release creation

extend software type list
parent f0384a74
from Products.ERP5Type.Message import translateString
portal = context.getPortalObject()
software_product = context
software_release = software_product.newContent(
# First, search if the release already exists
software_release_variation = portal.portal_catalog.getResultValue(
portal_type="Software Product Release Variation",
title=title,
url_string=url_string
url_string=software_release,
)
if software_release_variation is not None:
return software_release_variation.Base_redirect(
keep_items={
'portal_status_message': translateString('Software Release already exist.')
}
)
software_release_variation = software_product.newContent(
portal_type="Software Product Release Variation",
title=software_release,
url_string=software_release
)
if same_type(software_type_list, ""):
software_type_list = [software_type_list]
for software_type in software_type_list:
# Check if the software type already exist
software_type_variation = portal.portal_catalog.getResultValue(
portal_type="Software Product Type Variation",
parent_uid=software_product.getUid(),
title=software_type,
)
if software_type_variation is None:
software_product.newContent(
portal_type="Software Product Type Variation",
title=software_type
)
return software_release.Base_redirect(
return software_release_variation.Base_redirect(
keep_items={
'portal_status_message': translateString('New Software Release created.')
})
......@@ -50,7 +50,7 @@
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>title, url_string, **kw</string> </value>
<value> <string>software_release, software_type_list, **kw</string> </value>
</item>
<item>
<key> <string>id</string> </key>
......
......@@ -90,8 +90,7 @@
<key> <string>left</string> </key>
<value>
<list>
<string>your_title</string>
<string>your_url_string</string>
<string>your_product_import_json</string>
</list>
</value>
</item>
......
......@@ -10,15 +10,17 @@
<key> <string>delegated_list</string> </key>
<value>
<list>
<string>input_type</string>
<string>required</string>
<string>gadget_url</string>
<string>renderjs_extra</string>
<string>title</string>
<string>validator_field_id</string>
<string>validator_form_id</string>
</list>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>your_url_string</string> </value>
<value> <string>your_product_import_json</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
......@@ -58,6 +60,22 @@
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>gadget_url</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>validator_field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>validator_form_id</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
......@@ -67,23 +85,50 @@
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string>my_string_field</string> </value>
<value> <string>my_gadget_field</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>Base_viewFieldLibrary</string> </value>
</item>
<item>
<key> <string>input_type</string> </key>
<value> <string>url</string> </value>
<key> <string>gadget_url</string> </key>
<value> <string>slapos_master_panel_import_product.html</string> </value>
</item>
<item>
<key> <string>required</string> </key>
<value> <int>1</int> </value>
<key> <string>renderjs_extra</string> </key>
<value>
<list>
<tuple>
<string>title_key</string>
<string>title</string>
</tuple>
<tuple>
<string>description_key</string>
<string>description</string>
</tuple>
<tuple>
<string>software_release_key</string>
<string>software_release</string>
</tuple>
<tuple>
<string>software_type_key</string>
<string>software_type_list</string>
</tuple>
</list>
</value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Url String</string> </value>
<value> <string>Software Release</string> </value>
</item>
<item>
<key> <string>validator_field_id</string> </key>
<value> <string>my_core_mode_text_content_validator</string> </value>
</item>
<item>
<key> <string>validator_form_id</string> </key>
<value> <string>erp5_core/Base_viewFieldLibrary</string> </value>
</item>
</dictionary>
</value>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ProxyField" module="Products.ERP5Form.ProxyField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>delegated_list</string> </key>
<value>
<list>
<string>input_type</string>
<string>required</string>
<string>title</string>
</list>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>your_title</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
<value>
<dictionary>
<item>
<key> <string>external_validator_failed</string> </key>
<value> <string>The input failed the external validator.</string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string>my_string_field</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>Base_viewFieldLibrary</string> </value>
</item>
<item>
<key> <string>input_type</string> </key>
<value> <string>url</string> </value>
</item>
<item>
<key> <string>required</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Title</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
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