Commit 58b09a86 authored by Romain Courteaud's avatar Romain Courteaud

slapos_panel: factorize the schema url calculation in a python script

parent 977467b2
Pipeline #37259 failed with stage
in 0 seconds
...@@ -258,6 +258,7 @@ def makeTestSlapOSCodingStyleTestCase(tested_business_template): ...@@ -258,6 +258,7 @@ def makeTestSlapOSCodingStyleTestCase(tested_business_template):
'slapos_panel/Project_addSlapOSSoftwareProduct', 'slapos_panel/Project_addSlapOSSoftwareProduct',
'slapos_panel/Project_getComputeNodeTrackingList', 'slapos_panel/Project_getComputeNodeTrackingList',
'slapos_panel/Project_getPayableSoftwareProductPredicateList', 'slapos_panel/Project_getPayableSoftwareProductPredicateList',
'slapos_panel/Project_getSoftwareReleaseSchemaUrl',
'slapos_panel/Project_redirectSlapOSComputeNodeCertificate', 'slapos_panel/Project_redirectSlapOSComputeNodeCertificate',
'slapos_panel/Project_selectRequestInstanceTree', 'slapos_panel/Project_selectRequestInstanceTree',
'slapos_panel/Project_selectRequestSoftwareRelease', 'slapos_panel/Project_selectRequestSoftwareRelease',
......
...@@ -115,7 +115,7 @@ ...@@ -115,7 +115,7 @@
<dictionary> <dictionary>
<item> <item>
<key> <string>_text</string> </key> <key> <string>_text</string> </key>
<value> <string>python: [(\'parameter_xml\', context.getTextContent()), (\'restricted_softwaretype\', True), (\'softwaretype\', context.getSourceReference()), (\'json_url\', context.getUrlString().split(\'?\')[0] + \'.json\'), (\'restricted_softwaretype\', False), (\'shared\', context.isRootSlave())]</string> </value> <value> <string>python: [(\'parameter_xml\', context.getTextContent()), (\'restricted_softwaretype\', True), (\'softwaretype\', context.getSourceReference()), (\'json_url\', context.getFollowUpValue().Project_getSoftwareReleaseSchemaUrl(context.getUrlString())), (\'restricted_softwaretype\', False), (\'shared\', context.isRootSlave())]</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
from zExceptions import Unauthorized
if REQUEST is not None:
raise Unauthorized
# Ensure this script is called on the expected context
# for futur compatibility
assert context.getPortalType() == 'Project'
return software_release_url.split("?")[0] + ".json"
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="_reconstructor" module="copy_reg"/>
</klass>
<tuple>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
<global name="object" module="__builtin__"/>
<none/>
</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_url, REQUEST=None</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Project_getSoftwareReleaseSchemaUrl</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -115,7 +115,7 @@ ...@@ -115,7 +115,7 @@
<dictionary> <dictionary>
<item> <item>
<key> <string>_text</string> </key> <key> <string>_text</string> </key>
<value> <string>python: [(\'json_url\', request.get(\'field_your_url_string\').split(\'?\')[0] + \'.json\'), (\'restricted_softwaretype\', False), (\'software_type_list\', list(set([x.getSoftwareTypeTitle() for x in context.Project_getSoftwareProductPredicateList(software_product=context.getPortalObject().portal_catalog.getResultValue(portal_type=\'Software Product\', uid=request.get(\'field_your_aggregate_uid\')), software_product_release=context.getPortalObject().portal_catalog.getResultValue(portal_type=\'Software Product Release Variation\', parent_uid=request.get(\'field_your_aggregate_uid\'), url_string=request.get(\'field_your_url_string\')))])))]</string> </value> <value> <string>python: [(\'json_url\', context.Project_getSoftwareReleaseSchemaUrl(request.get(\'field_your_url_string\'))), (\'restricted_softwaretype\', False), (\'software_type_list\', list(set([x.getSoftwareTypeTitle() for x in context.Project_getSoftwareProductPredicateList(software_product=context.getPortalObject().portal_catalog.getResultValue(portal_type=\'Software Product\', uid=request.get(\'field_your_aggregate_uid\')), software_product_release=context.getPortalObject().portal_catalog.getResultValue(portal_type=\'Software Product Release Variation\', parent_uid=request.get(\'field_your_aggregate_uid\'), url_string=request.get(\'field_your_url_string\')))])))]</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
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