Commit 9013c2c9 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_cloud&jio&erp5: Introduce Person.requestNetwork

parent e3d83856
...@@ -7,6 +7,10 @@ ...@@ -7,6 +7,10 @@
<type>Compute Partition</type> <type>Compute Partition</type>
<workflow>compute_partition_slap_interface_workflow</workflow> <workflow>compute_partition_slap_interface_workflow</workflow>
</chain> </chain>
<chain>
<type>Computer Network</type>
<workflow>computer_network_slap_interface_workflow</workflow>
</chain>
<chain> <chain>
<type>Hosting Subscription</type> <type>Hosting Subscription</type>
<workflow>edit_workflow</workflow> <workflow>edit_workflow</workflow>
......
portal = context.getPortalObject()
reference = "NET-%s" % portal.portal_ids.generateNewId(
id_group='slap_network_reference',
id_generator='uid')
context.edit(reference=reference)
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Workflow" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_count</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>_mt_index</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>_tree</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>source/portal_workflow/network_slap_interface_workflow/state_draft</string>
</tuple>
</value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>person_slap_interface_workflow</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>network_slap_interface_workflow</string> </value>
</item>
<item>
<key> <string>language</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>manager_bypass</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Workflow</string> </value>
</item>
<item>
<key> <string>state_variable</string> </key>
<value> <string>slap_state</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Network Slap Interface Workflow</string> </value>
</item>
<item>
<key> <string>workflow_managed_permission</string> </key>
<value>
<tuple/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="Length" module="BTrees.Length"/>
</pickle>
<pickle> <int>0</int> </pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="OOBTree" module="BTrees.OOBTree"/>
</pickle>
<pickle>
<none/>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="OOBTree" module="BTrees.OOBTree"/>
</pickle>
<pickle>
<none/>
</pickle>
</record>
</ZopeData>
computer_network = state_change["object"]
from DateTime import DateTime
portal = computer_network.getPortalObject()
if computer_network.getReference() in [None, ""]:
reference = "NET-%s" % portal.portal_ids.generateNewId(
id_group='slap_network_reference',
id_generator='uid')
computer_network.setReference(reference)
computer_network.validate()
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<ZopeData> <ZopeData>
<record id="1" aka="AAAAAAAAAAE="> <record id="1" aka="AAAAAAAAAAE=">
<pickle> <pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/> <global name="Workflow Script" module="erp5.portal_type"/>
</pickle> </pickle>
<pickle> <pickle>
<dictionary> <dictionary>
...@@ -50,42 +50,33 @@ ...@@ -50,42 +50,33 @@
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string>**kw</string> </value> <value> <string>state_change</string> </value>
</item> </item>
<item> <item>
<key> <string>_proxy_roles</string> </key> <key> <string>_proxy_roles</string> </key>
<value> <value>
<tuple> <tuple>
<string>Owner</string> <string>Manager</string>
</tuple> </tuple>
</value> </value>
</item> </item>
<item> <item>
<key> <string>guard</string> </key> <key> <string>description</string> </key>
<value> <value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent> <none/>
</value> </value>
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>ComputerNetwork_init</string> </value> <value> <string>script_ComputerNetwork_approveRegistration</string> </value>
</item> </item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="Guard" module="Products.DCWorkflow.Guard"/>
</pickle>
<pickle>
<dictionary>
<item> <item>
<key> <string>roles</string> </key> <key> <string>portal_type</string> </key>
<value> <value> <string>Workflow Script</string> </value>
<tuple> </item>
<string>Owner</string> <item>
</tuple> <key> <string>title</string> </key>
</value> <value> <string>ComputerNetwork_approveRegistration</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
...@@ -50,19 +50,17 @@ ...@@ -50,19 +50,17 @@
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string>state_object</string> </value> <value> <string>state_change</string> </value>
</item> </item>
<item> <item>
<key> <string>_proxy_roles</string> </key> <key> <string>description</string> </key>
<value> <value>
<tuple> <none/>
<string>Manager</string>
</tuple>
</value> </value>
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>script_ComputerNetwork_validate</string> </value> <value> <string>script_ComputerNetwork_checkConsistency</string> </value>
</item> </item>
<item> <item>
<key> <string>portal_type</string> </key> <key> <string>portal_type</string> </key>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Workflow State" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>acquire_permission</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>destination/portal_workflow/network_slap_interface_workflow/transition_approve_registration</string>
</tuple>
</value>
</item>
<item>
<key> <string>comment</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>state_draft</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Workflow State</string> </value>
</item>
<item>
<key> <string>state_permission_role_list_dict</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>state_type</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Draft</string> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -2,61 +2,61 @@ ...@@ -2,61 +2,61 @@
<ZopeData> <ZopeData>
<record id="1" aka="AAAAAAAAAAE="> <record id="1" aka="AAAAAAAAAAE=">
<pickle> <pickle>
<global name="Interaction Workflow Interaction" module="erp5.portal_type"/> <global name="Workflow Transition" module="erp5.portal_type"/>
</pickle> </pickle>
<pickle> <pickle>
<dictionary> <dictionary>
<item> <item>
<key> <string>categories</string> </key> <key> <string>action</string> </key>
<value> <value>
<tuple> <none/>
<string>before_commit_script/portal_workflow/slapos_erp5_interaction_workflow/script_ComputerNetwork_validate</string>
</tuple>
</value> </value>
</item> </item>
<item> <item>
<key> <string>description</string> </key> <key> <string>action_name</string> </key>
<value> <value>
<none/> <none/>
</value> </value>
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>categories</string> </key>
<value> <string>interaction_ComputerNetwork_setRefence</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Interaction Workflow Interaction</string> </value>
</item>
<item>
<key> <string>portal_type_filter</string> </key>
<value> <value>
<tuple> <tuple>
<string>Computer Network</string> <string>action_type/workflow</string>
<string>before_script/portal_workflow/network_slap_interface_workflow/script_ComputerNetwork_checkConsistency</string>
<string>after_script/portal_workflow/network_slap_interface_workflow/script_ComputerNetwork_approveRegistration</string>
</tuple> </tuple>
</value> </value>
</item> </item>
<item> <item>
<key> <string>portal_type_group_filter</string> </key> <key> <string>description</string> </key>
<value> <value>
<tuple/> <none/>
</value> </value>
</item> </item>
<item> <item>
<key> <string>temporary_document_disallowed</string> </key> <key> <string>guard_permission</string> </key>
<value> <int>0</int> </value> <value>
<tuple/>
</value>
</item> </item>
<item> <item>
<key> <string>trigger_method_id</string> </key> <key> <string>icon</string> </key>
<value> <value>
<tuple> <none/>
<string>_setReference*</string>
</tuple>
</value> </value>
</item> </item>
<item> <item>
<key> <string>trigger_once_per_transaction</string> </key> <key> <string>id</string> </key>
<value> <int>0</int> </value> <value> <string>transition_approve_registration</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Workflow Transition</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Approve Registration</string> </value>
</item> </item>
<item> <item>
<key> <string>trigger_type</string> </key> <key> <string>trigger_type</string> </key>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Workflow Variable" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>automatic_update</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>The last transition</string> </value>
</item>
<item>
<key> <string>for_catalog</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>variable_action</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Workflow Variable</string> </value>
</item>
<item>
<key> <string>status_included</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>variable_default_expression</string> </key>
<value> <string>transition/getReference|nothing</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Workflow Variable" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>automatic_update</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>The name of the user who performed the last transition</string> </value>
</item>
<item>
<key> <string>for_catalog</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>variable_actor</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Workflow Variable</string> </value>
</item>
<item>
<key> <string>status_included</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>variable_default_expression</string> </key>
<value> <string>user/getUserName</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Workflow Variable" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>automatic_update</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>Comments about the last transition</string> </value>
</item>
<item>
<key> <string>for_catalog</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>variable_comment</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Workflow Variable</string> </value>
</item>
<item>
<key> <string>status_included</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>variable_default_expression</string> </key>
<value> <string>python:state_change.kwargs.get(\'comment\', \'\')</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Workflow Variable" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>automatic_update</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>Error message if validation failed</string> </value>
</item>
<item>
<key> <string>for_catalog</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>variable_error_message</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Workflow Variable</string> </value>
</item>
<item>
<key> <string>status_included</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value>
<none/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Workflow Variable" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>automatic_update</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>Provides access to workflow history</string> </value>
</item>
<item>
<key> <string>for_catalog</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>variable_history</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Workflow Variable</string> </value>
</item>
<item>
<key> <string>status_included</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>variable_default_expression</string> </key>
<value> <string>state_change/getHistory</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Workflow Variable" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>automatic_update</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>portal type (use as filter for worklists)</string> </value>
</item>
<item>
<key> <string>for_catalog</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>variable_portal_type</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Workflow Variable</string> </value>
</item>
<item>
<key> <string>status_included</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value>
<none/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Workflow Variable" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>automatic_update</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>Time of the last transition</string> </value>
</item>
<item>
<key> <string>for_catalog</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>variable_time</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Workflow Variable</string> </value>
</item>
<item>
<key> <string>status_included</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>variable_default_expression</string> </key>
<value> <string>state_change/getDateTime</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
person = state_change['object']
portal = person.getPortalObject()
# Get required arguments
kwargs = state_change.kwargs
# Required args
# Raise TypeError if all parameters are not provided
try:
computer_network_title = kwargs['network_title']
except KeyError:
raise TypeError, "Person_requestNetwork takes exactly 1 argument"
tag = "%s_%s_NetworkInProgress" % (person.getUid(),
computer_network_title)
if (portal.portal_activities.countMessageWithTag(tag) > 0):
# The software instance is already under creation but can not be fetched from catalog
# As it is not possible to fetch informations, it is better to raise an error
raise NotImplementedError(tag)
computer_network_portal_type = "Computer Network"
computer_network_list = portal.portal_catalog.portal_catalog(
portal_type=computer_network_portal_type,
title=computer_network_title,
validation_state="validated",
limit=2)
if len(computer_network_list) == 2:
raise NotImplementedError
elif len(computer_network_list) == 1:
context.REQUEST.set("computer_network_relative_url", computer_network_list[0].getRelativeUrl())
context.REQUEST.set("computer_network_reference", computer_network_list[0].getReference())
else:
module = portal.getDefaultModule(portal_type=computer_network_portal_type)
computer_network = module.newContent(
portal_type=computer_network_portal_type,
title=computer_network_title,
source_administration=person.getRelativeUrl(),
activate_kw={'tag': tag}
)
context.REQUEST.set("computer_network_relative_url", computer_network.getRelativeUrl())
context.REQUEST.set("computer_network_reference", computer_network.getReference())
computer_network.approveRegistration()
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Workflow Script" module="erp5.portal_type"/>
</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>state_change</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>script_Person_requestNetwork</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Workflow Script</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Person_requestNetwork</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
<key> <string>categories</string> </key> <key> <string>categories</string> </key>
<value> <value>
<tuple> <tuple>
<string>destination/portal_workflow/person_slap_interface_workflow/transition_request_network</string>
<string>destination/portal_workflow/person_slap_interface_workflow/transition_request_compute_node</string> <string>destination/portal_workflow/person_slap_interface_workflow/transition_request_compute_node</string>
<string>destination/portal_workflow/person_slap_interface_workflow/transition_request_organisation</string> <string>destination/portal_workflow/person_slap_interface_workflow/transition_request_organisation</string>
<string>destination/portal_workflow/person_slap_interface_workflow/transition_request_project</string> <string>destination/portal_workflow/person_slap_interface_workflow/transition_request_project</string>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Workflow Transition" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>action</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>action_name</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>action_type/workflow</string>
<string>before_script/portal_workflow/person_slap_interface_workflow/script_Person_checkConsistency</string>
<string>after_script/portal_workflow/person_slap_interface_workflow/script_Person_requestNetwork</string>
</tuple>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>guard_permission</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>icon</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>transition_request_network</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Workflow Transition</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Request Network</string> </value>
</item>
<item>
<key> <string>trigger_type</string> </key>
<value> <int>2</int> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
Compute Node | compute_node_slap_interface_workflow Compute Node | compute_node_slap_interface_workflow
Compute Node | slapos_cloud_interaction_workflow Compute Node | slapos_cloud_interaction_workflow
Compute Partition | compute_partition_slap_interface_workflow Compute Partition | compute_partition_slap_interface_workflow
Computer Network | computer_network_slap_interface_workflow
Hosting Subscription | edit_workflow Hosting Subscription | edit_workflow
Instance Tree | edit_workflow Instance Tree | edit_workflow
Instance Tree | instance_slap_interface_workflow Instance Tree | instance_slap_interface_workflow
......
...@@ -4,6 +4,7 @@ compute_partition_slap_interface_workflow ...@@ -4,6 +4,7 @@ compute_partition_slap_interface_workflow
installation_slap_interface_workflow installation_slap_interface_workflow
instance_slap_interface_workflow instance_slap_interface_workflow
instance_tree_workflow instance_tree_workflow
network_slap_interface_workflow
organisation_slap_interface_workflow organisation_slap_interface_workflow
person_slap_interface_workflow person_slap_interface_workflow
project_slap_interface_workflow project_slap_interface_workflow
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
</chain> </chain>
<chain> <chain>
<type>Computer Network</type> <type>Computer Network</type>
<workflow>local_permission_slapos_interaction_workflow, slapos_erp5_interaction_workflow</workflow> <workflow>local_permission_slapos_interaction_workflow</workflow>
</chain> </chain>
<chain> <chain>
<type>Contract Invitation Token</type> <type>Contract Invitation Token</type>
......
...@@ -252,80 +252,3 @@ class TestSlapOSERP5InteractionWorkflowComputeNodeSetAllocationScope( ...@@ -252,80 +252,3 @@ class TestSlapOSERP5InteractionWorkflowComputeNodeSetAllocationScope(
self.assertEqual(compute_node.getSubjectList(), [person.getDefaultEmailCoordinateText()]) self.assertEqual(compute_node.getSubjectList(), [person.getDefaultEmailCoordinateText()])
self.assertEqual(compute_node.getDestinationSectionList(), self.assertEqual(compute_node.getDestinationSectionList(),
[person.getRelativeUrl()]) [person.getRelativeUrl()])
class TestSlapOSERP5InteractionWorkflowComputerNetworkSetReference(
SlapOSTestCaseMixin):
def test_ComputerNetwork_validate(self):
computer_network = self.portal.computer_network_module.newContent(
portal_type="Computer Network"
)
self.commit()
self.assertNotEqual(computer_network.getReference(), None)
self.assertEqual(computer_network.getValidationState(), "validated")
self.assertEqual(computer_network.getSourceAdministration(), None)
@simulate("ComputerNetwork_init", "*args, **kwargs", "return")
def test_ComputerNetwork_validate_manual(self):
computer_network = self.portal.computer_network_module.newContent(
portal_type="Computer Network"
)
self.commit()
self.assertEqual(computer_network.getReference(), None)
self.assertEqual(computer_network.getValidationState(), "draft")
self.assertEqual(computer_network.getSourceAdministration(), None)
computer_network.setReference(
"COMPNTEST-%s" % self.new_id
)
self.tic()
self.assertNotEqual(computer_network.getReference(), None)
self.assertEqual(computer_network.getValidationState(), "validated")
self.assertEqual(computer_network.getSourceAdministration(), None)
@simulate("ComputerNetwork_init", "*args, **kwargs", "return")
def test_ComputerNetwork_validate_manual_with_user(self):
person = self.makePerson(user=True)
self.login(person.getUserId())
computer_network = self.portal.computer_network_module.newContent(
portal_type="Computer Network"
)
self.commit()
self.assertEqual(computer_network.getReference(), None)
self.assertEqual(computer_network.getValidationState(), "draft")
self.assertEqual(computer_network.getSourceAdministration(), None)
computer_network.setReference(
"COMPNTEST-%s" % self.new_id
)
self.tic()
self.assertNotEqual(computer_network.getReference(), None)
self.assertEqual(computer_network.getValidationState(), "validated")
self.assertEqual(computer_network.getSourceAdministration(),
person.getRelativeUrl())
@simulate("ComputerNetwork_init", "*args, **kwargs", "return")
def test_ComputerNetwork_validate_manual_already_validated(self):
person = self.makePerson(user=True)
self.login(person.getUserId())
computer_network = self.portal.computer_network_module.newContent(
portal_type="Computer Network"
)
computer_network.validate()
self.commit()
self.assertEqual(computer_network.getReference(), None)
self.assertEqual(computer_network.getValidationState(), "validated")
self.assertEqual(computer_network.getSourceAdministration(), None)
computer_network.setReference(
"COMPNTEST-%s" % self.new_id
)
self.tic()
self.assertNotEqual(computer_network.getReference(), None)
self.assertEqual(computer_network.getValidationState(), "validated")
self.assertEqual(computer_network.getSourceAdministration(),
None)
\ No newline at end of file
computer_network = state_object["object"]
portal = context.getPortalObject()
person = portal.portal_membership.getAuthenticatedMember().getUserValue()
if person is not None and computer_network.getValidationState() == "draft":
computer_network.edit(
source_administration=person.getRelativeUrl()
)
if computer_network.getValidationState() == "draft":
computer_network.validate()
...@@ -4,7 +4,6 @@ Compute Node | local_permission_slapos_interaction_workflow ...@@ -4,7 +4,6 @@ Compute Node | local_permission_slapos_interaction_workflow
Compute Node | slapos_erp5_interaction_workflow Compute Node | slapos_erp5_interaction_workflow
Computer Model | local_permission_slapos_interaction_workflow Computer Model | local_permission_slapos_interaction_workflow
Computer Network | local_permission_slapos_interaction_workflow Computer Network | local_permission_slapos_interaction_workflow
Computer Network | slapos_erp5_interaction_workflow
Contract Invitation Token | edit_workflow Contract Invitation Token | edit_workflow
Contract Invitation Token | validation_workflow Contract Invitation Token | validation_workflow
Delivery Cell | -immobilisation_movement_interaction_workflow Delivery Cell | -immobilisation_movement_interaction_workflow
...@@ -19,7 +18,6 @@ Inventory | -immobilisation_movement_interaction_workflow ...@@ -19,7 +18,6 @@ Inventory | -immobilisation_movement_interaction_workflow
Invitation Token | edit_workflow Invitation Token | edit_workflow
Invitation Token | validation_workflow Invitation Token | validation_workflow
Organisation | local_permission_slapos_interaction_workflow Organisation | local_permission_slapos_interaction_workflow
Organisation | slapos_erp5_interaction_workflow
Payment Transaction | local_permission_slapos_interaction_workflow Payment Transaction | local_permission_slapos_interaction_workflow
Payzen Event | local_permission_slapos_interaction_workflow Payzen Event | local_permission_slapos_interaction_workflow
Person | local_permission_slapos_interaction_workflow Person | local_permission_slapos_interaction_workflow
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
.declareAcquiredMethod("getSetting", "getSetting") .declareAcquiredMethod("getSetting", "getSetting")
.declareAcquiredMethod("getUrlFor", "getUrlFor") .declareAcquiredMethod("getUrlFor", "getUrlFor")
.declareAcquiredMethod("redirect", "redirect") .declareAcquiredMethod("redirect", "redirect")
.declareAcquiredMethod("jio_post", "jio_post") .declareAcquiredMethod("jio_getAttachment", "jio_getAttachment")
.declareAcquiredMethod("notifySubmitting", "notifySubmitting") .declareAcquiredMethod("notifySubmitting", "notifySubmitting")
.declareAcquiredMethod("notifySubmitted", 'notifySubmitted') .declareAcquiredMethod("notifySubmitted", 'notifySubmitted')
.declareAcquiredMethod("getTranslationList", "getTranslationList") .declareAcquiredMethod("getTranslationList", "getTranslationList")
...@@ -31,17 +31,23 @@ ...@@ -31,17 +31,23 @@
return gadget.getDeclaredGadget('form_view'); return gadget.getDeclaredGadget('form_view');
}) })
.push(function (form_gadget) { .push(function (form_gadget) {
return form_gadget.getContent(); return RSVP.all([form_gadget.getContent(),
gadget.getSetting('me')]);
}) })
.push(function (doc) { .push(function (result) {
return gadget.jio_post(doc); var doc = result[0], me = result[1];
return gadget.getSetting("hateoas_url")
.push(function (url) {
return gadget.jio_getAttachment(me,
url + me + "/Person_requestNetwork?title=" + doc.title);
});
}) })
.push(function (key) { .push(function (result) {
return gadget.notifySubmitted({message: gadget.message_translation, status: 'success'}) return gadget.notifySubmitted({message: gadget.message_translation, status: 'success'})
.push(function () { .push(function () {
// Workaround, find a way to open document without break gadget. // Workaround, find a way to open document without break gadget.
return gadget.redirect({"command": "change", return gadget.redirect({"command": "change",
"options": {"jio_key": key, "page": "slap_controller"}}); "options": {"jio_key": result.relative_url, "page": "slap_controller"}});
}); });
}); });
}) })
...@@ -83,28 +89,6 @@ ...@@ -83,28 +89,6 @@
"key": "title", "key": "title",
"hidden": 0, "hidden": 0,
"type": "StringField" "type": "StringField"
},
"my_portal_type": {
"description": "The name of a document in ERP5",
"title": result[1][1],
"default": "Computer Network",
"css_class": "",
"required": 1,
"editable": 1,
"key": "portal_type",
"hidden": 1,
"type": "StringField"
},
"my_parent_relative_url": {
"description": "",
"title": result[1][2],
"default": "computer_network_module",
"css_class": "",
"required": 1,
"editable": 1,
"key": "parent_relative_url",
"hidden": 1,
"type": "StringField"
} }
}}, }},
"_links": { "_links": {
...@@ -117,7 +101,7 @@ ...@@ -117,7 +101,7 @@
form_definition: { form_definition: {
group_list: [[ group_list: [[
"left", "left",
[["my_title"], ["my_portal_type"], ["my_parent_relative_url"]] [["my_title"]]
]] ]]
} }
}); });
......
...@@ -279,7 +279,7 @@ ...@@ -279,7 +279,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>987.11840.22638.11383</string> </value> <value> <string>996.48626.19826.13090</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -297,7 +297,7 @@ ...@@ -297,7 +297,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1602261150.28</float> <float>1639166593.8</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
import json
portal = context.getPortalObject()
person = portal.portal_membership.getAuthenticatedMember().getUserValue()
request = context.REQUEST
response = request.RESPONSE
if person is None:
response.setStatus(403)
else:
request_kw = dict(network_title=title)
person.requestNetwork(**request_kw)
network_relative_url = context.REQUEST.get('computer_network_relative_url')
network_reference = context.REQUEST.get('computer_network_reference')
return json.dumps({
"reference": network_reference,
"relative_url": network_relative_url
})
<?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>title</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Person_requestNetwork</string> </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