From 3b0ba9e67e91435a8dbba4364f376012720bfa12 Mon Sep 17 00:00:00 2001
From: Romain Courteaud <romain@nexedi.com>
Date: Tue, 18 Sep 2012 10:47:49 +0200
Subject: [PATCH] Drop the customer informations form.

Move the instance parameters filling at the end of the process.
---
 ...dSelectedSoftwareProductToShoppingCart.xml |  24 +--
 .../WebSection_setInstanceParameter.xml       | 120 ++++++++++++++
 ...WebSection_viewInstanceParameterDialog.xml | 150 ++++++++++++++++++
 .../my_description.xml                        | 115 ++++++++++++++
 .../your_computer.xml                         |   0
 .../your_instance_xml.xml                     |   0
 .../your_service_title.xml                    |  17 +-
 .../your_shared.xml                           |   2 +-
 .../WebSection_viewServiceChoiceDialog.xml    |   4 -
 master/bt5/vifib_web/bt/revision              |   2 +-
 10 files changed, 404 insertions(+), 30 deletions(-)
 create mode 100644 master/bt5/vifib_web/SkinTemplateItem/portal_skins/vifib_hosting/WebSection_setInstanceParameter.xml
 create mode 100644 master/bt5/vifib_web/SkinTemplateItem/portal_skins/vifib_hosting/WebSection_viewInstanceParameterDialog.xml
 create mode 100644 master/bt5/vifib_web/SkinTemplateItem/portal_skins/vifib_hosting/WebSection_viewInstanceParameterDialog/my_description.xml
 rename master/bt5/vifib_web/SkinTemplateItem/portal_skins/vifib_hosting/{WebSection_viewServiceChoiceDialog => WebSection_viewInstanceParameterDialog}/your_computer.xml (100%)
 rename master/bt5/vifib_web/SkinTemplateItem/portal_skins/vifib_hosting/{WebSection_viewServiceChoiceDialog => WebSection_viewInstanceParameterDialog}/your_instance_xml.xml (100%)
 rename master/bt5/vifib_web/SkinTemplateItem/portal_skins/vifib_hosting/{WebSection_viewServiceChoiceDialog => WebSection_viewInstanceParameterDialog}/your_service_title.xml (94%)
 rename master/bt5/vifib_web/SkinTemplateItem/portal_skins/vifib_hosting/{WebSection_viewServiceChoiceDialog => WebSection_viewInstanceParameterDialog}/your_shared.xml (99%)

diff --git a/master/bt5/vifib_web/SkinTemplateItem/portal_skins/vifib_hosting/WebSection_addSelectedSoftwareProductToShoppingCart.xml b/master/bt5/vifib_web/SkinTemplateItem/portal_skins/vifib_hosting/WebSection_addSelectedSoftwareProductToShoppingCart.xml
index 0b91b7eb8..ee3c1cbd9 100644
--- a/master/bt5/vifib_web/SkinTemplateItem/portal_skins/vifib_hosting/WebSection_addSelectedSoftwareProductToShoppingCart.xml
+++ b/master/bt5/vifib_web/SkinTemplateItem/portal_skins/vifib_hosting/WebSection_addSelectedSoftwareProductToShoppingCart.xml
@@ -57,31 +57,9 @@ if len(uids) != 1:\n
   return context.Base_redirect(dialog_id,\n
                         keep_items={\'portal_status_message\':context.Base_translateString("Please select one service.")})\n
 \n
-if not service_title:\n
-  return context.Base_redirect(dialog_id,\n
-                        keep_items={\'portal_status_message\':context.Base_translateString("You have to provide Service Title.")})\n
-\n
-cleanup_resource = portal.portal_preferences.getPreferredInstanceCleanupResource()\n
-software_instance_list = []\n
-hosting_subscription = portal.portal_catalog.getResultValue(\n
-  portal_type=\'Hosting Subscription\',\n
-  validation_state="validated",\n
-  select_expression=\'title\',\n
-  title={\'query\': service_title, \'key\': \'ExactMatch\'}\n
-  )\n
-\n
-if hosting_subscription is not None:\n
-  return context.Base_redirect(dialog_id,\n
-                        keep_items={\'portal_status_message\':context.Base_translateString(\n
-                          "You already have service named ${service_title}. Please choose different unique name.", mapping={\'service_title\': service_title})})\n
-\n
 session = context.WebSection_getVifibSession()\n
 params = portal.portal_selections.getSelectionParamsFor(\'vifib_session_id\')\n
 params["instance_software_product_uid"] = uids[0]\n
-params["service_title"] = service_title\n
-params["instance_xml"] = instance_xml\n
-params["shared"] = shared\n
-params["computer"] = computer\n
 portal.portal_selections.setSelectionParamsFor(\'vifib_session_id\', params)\n
 \n
 if kw.has_key(\'came_from\'):\n
@@ -93,7 +71,7 @@ context.WebSection_viewNextStep()\n
         </item>
         <item>
             <key> <string>_params</string> </key>
-            <value> <string>dialog_id, service_title, instance_xml, computer=\'\', uids=[], shared=0, quantity=1, reset_shopping_cart=True, **kw</string> </value>
+            <value> <string>dialog_id, uids=[], quantity=1, reset_shopping_cart=True, **kw</string> </value>
         </item>
         <item>
             <key> <string>id</string> </key>
diff --git a/master/bt5/vifib_web/SkinTemplateItem/portal_skins/vifib_hosting/WebSection_setInstanceParameter.xml b/master/bt5/vifib_web/SkinTemplateItem/portal_skins/vifib_hosting/WebSection_setInstanceParameter.xml
new file mode 100644
index 000000000..557a5faaf
--- /dev/null
+++ b/master/bt5/vifib_web/SkinTemplateItem/portal_skins/vifib_hosting/WebSection_setInstanceParameter.xml
@@ -0,0 +1,120 @@
+<?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>_body</string> </key>
+            <value> <string encoding="cdata"><![CDATA[
+
+# dialog_id, service_title, instance_xml, computer=\'\', uids=[], shared=0, quantity=1, reset_shopping_cart=True, **kw\n
+"""Set the instance request parameter"""\n
+portal = context.getPortalObject()\n
+\n
+if not service_title:\n
+  return context.Base_redirect(dialog_id,\n
+                        keep_items={\'portal_status_message\':context.Base_translateString("You have to provide Service Title.")})\n
+\n
+hosting_subscription = portal.portal_catalog.getResultValue(\n
+  portal_type=\'Hosting Subscription\',\n
+  validation_state="validated",\n
+  select_expression=\'title\',\n
+  title={\'query\': service_title, \'key\': \'ExactMatch\'}\n
+  )\n
+\n
+if hosting_subscription is not None:\n
+  return context.Base_redirect(dialog_id,\n
+                        keep_items={\'portal_status_message\':context.Base_translateString(\n
+                          "You already have service named ${service_title}. Please choose different unique name.", mapping={\'service_title\': service_title})})\n
+\n
+\n
+# return context.WebSection_viewNextStep()\n
+session = context.WebSection_getVifibSession()\n
+params = portal.portal_selections.getSelectionParamsFor(\'vifib_session_id\')\n
+instance_software_release_uid = params[\'instance_software_release_uid\']\n
+software_release = portal.portal_catalog.getResultValue(uid=instance_software_release_uid)\n
+\n
+request_kw = {}\n
+request_kw.update(\n
+  software_release=software_release.getUrlString(),\n
+  software_title=service_title,\n
+  software_type="RootSoftwareInstance",\n
+  instance_xml=instance_xml,\n
+  sla_xml="",\n
+  shared=False,\n
+  state="started",\n
+)\n
+\n
+if computer:\n
+  computer = context.restrictedTraverse(computer)\n
+  request_kw[\'sla_xml\'] = """<?xml version=\'1.0\' encoding=\'utf-8\'?>\n
+<instance>\n
+<parameter id="computer_guid">%s</parameter>\n
+</instance>""" % computer.getReference()\n
+\n
+person = portal.ERP5Site_getAuthenticatedMemberPersonValue()\n
+person.requestSoftwareInstance(**request_kw)\n
+\n
+message = context.Base_translateString("Your instance is under creation. Please wait few minutes for partitions to appear.")\n
+return context.REQUEST.get(\'request_hosting_subscription\').Base_redirect(keep_items={\'portal_status_message\': message})\n
+
+
+]]></string> </value>
+        </item>
+        <item>
+            <key> <string>_params</string> </key>
+            <value> <string>dialog_id, service_title, instance_xml, computer=\'\', shared=0, **kw</string> </value>
+        </item>
+        <item>
+            <key> <string>id</string> </key>
+            <value> <string>WebSection_setInstanceParameter</string> </value>
+        </item>
+      </dictionary>
+    </pickle>
+  </record>
+</ZopeData>
diff --git a/master/bt5/vifib_web/SkinTemplateItem/portal_skins/vifib_hosting/WebSection_viewInstanceParameterDialog.xml b/master/bt5/vifib_web/SkinTemplateItem/portal_skins/vifib_hosting/WebSection_viewInstanceParameterDialog.xml
new file mode 100644
index 000000000..cd64e6ed1
--- /dev/null
+++ b/master/bt5/vifib_web/SkinTemplateItem/portal_skins/vifib_hosting/WebSection_viewInstanceParameterDialog.xml
@@ -0,0 +1,150 @@
+<?xml version="1.0"?>
+<ZopeData>
+  <record id="1" aka="AAAAAAAAAAE=">
+    <pickle>
+      <global name="ERP5Form" module="Products.ERP5Form.Form"/>
+    </pickle>
+    <pickle>
+      <dictionary>
+        <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/>
+                        </value>
+                    </item>
+                  </dictionary>
+                </state>
+              </object>
+            </value>
+        </item>
+        <item>
+            <key> <string>_objects</string> </key>
+            <value>
+              <tuple/>
+            </value>
+        </item>
+        <item>
+            <key> <string>action</string> </key>
+            <value> <string>WebSection_setInstanceParameter</string> </value>
+        </item>
+        <item>
+            <key> <string>description</string> </key>
+            <value> <string></string> </value>
+        </item>
+        <item>
+            <key> <string>edit_order</string> </key>
+            <value>
+              <list/>
+            </value>
+        </item>
+        <item>
+            <key> <string>encoding</string> </key>
+            <value> <string>UTF-8</string> </value>
+        </item>
+        <item>
+            <key> <string>enctype</string> </key>
+            <value> <string></string> </value>
+        </item>
+        <item>
+            <key> <string>group_list</string> </key>
+            <value>
+              <list>
+                <string>normal</string>
+                <string>left</string>
+                <string>right</string>
+                <string>hidden</string>
+              </list>
+            </value>
+        </item>
+        <item>
+            <key> <string>groups</string> </key>
+            <value>
+              <dictionary>
+                <item>
+                    <key> <string>hidden</string> </key>
+                    <value>
+                      <list>
+                        <string>your_shared</string>
+                      </list>
+                    </value>
+                </item>
+                <item>
+                    <key> <string>left</string> </key>
+                    <value>
+                      <list/>
+                    </value>
+                </item>
+                <item>
+                    <key> <string>normal</string> </key>
+                    <value>
+                      <list>
+                        <string>my_description</string>
+                        <string>your_service_title</string>
+                        <string>your_instance_xml</string>
+                        <string>your_computer</string>
+                      </list>
+                    </value>
+                </item>
+                <item>
+                    <key> <string>right</string> </key>
+                    <value>
+                      <list/>
+                    </value>
+                </item>
+              </dictionary>
+            </value>
+        </item>
+        <item>
+            <key> <string>id</string> </key>
+            <value> <string>WebSection_viewInstanceParameterDialog</string> </value>
+        </item>
+        <item>
+            <key> <string>method</string> </key>
+            <value> <string>POST</string> </value>
+        </item>
+        <item>
+            <key> <string>name</string> </key>
+            <value> <string>WebSection_viewCustomerInformationsDialog</string> </value>
+        </item>
+        <item>
+            <key> <string>pt</string> </key>
+            <value> <string>form_dialog</string> </value>
+        </item>
+        <item>
+            <key> <string>row_length</string> </key>
+            <value> <int>4</int> </value>
+        </item>
+        <item>
+            <key> <string>stored_encoding</string> </key>
+            <value> <string>UTF-8</string> </value>
+        </item>
+        <item>
+            <key> <string>title</string> </key>
+            <value> <string>Continue</string> </value>
+        </item>
+        <item>
+            <key> <string>unicode_mode</string> </key>
+            <value> <int>0</int> </value>
+        </item>
+        <item>
+            <key> <string>update_action</string> </key>
+            <value> <string></string> </value>
+        </item>
+        <item>
+            <key> <string>update_action_title</string> </key>
+            <value> <string></string> </value>
+        </item>
+      </dictionary>
+    </pickle>
+  </record>
+</ZopeData>
diff --git a/master/bt5/vifib_web/SkinTemplateItem/portal_skins/vifib_hosting/WebSection_viewInstanceParameterDialog/my_description.xml b/master/bt5/vifib_web/SkinTemplateItem/portal_skins/vifib_hosting/WebSection_viewInstanceParameterDialog/my_description.xml
new file mode 100644
index 000000000..2d8ff8eec
--- /dev/null
+++ b/master/bt5/vifib_web/SkinTemplateItem/portal_skins/vifib_hosting/WebSection_viewInstanceParameterDialog/my_description.xml
@@ -0,0 +1,115 @@
+<?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>default</string>
+              </list>
+            </value>
+        </item>
+        <item>
+            <key> <string>id</string> </key>
+            <value> <string>my_description</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>
+                <item>
+                    <key> <string>target</string> </key>
+                    <value> <string></string> </value>
+                </item>
+              </dictionary>
+            </value>
+        </item>
+        <item>
+            <key> <string>tales</string> </key>
+            <value>
+              <dictionary>
+                <item>
+                    <key> <string>default</string> </key>
+                    <value>
+                      <persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
+                    </value>
+                </item>
+                <item>
+                    <key> <string>field_id</string> </key>
+                    <value> <string></string> </value>
+                </item>
+                <item>
+                    <key> <string>form_id</string> </key>
+                    <value> <string></string> </value>
+                </item>
+                <item>
+                    <key> <string>target</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_translated_description</string> </value>
+                </item>
+                <item>
+                    <key> <string>form_id</string> </key>
+                    <value> <string>Base_viewWebFieldLibrary</string> </value>
+                </item>
+                <item>
+                    <key> <string>target</string> </key>
+                    <value> <string>Click to edit the target</string> </value>
+                </item>
+              </dictionary>
+            </value>
+        </item>
+      </dictionary>
+    </pickle>
+  </record>
+  <record id="2" aka="AAAAAAAAAAI=">
+    <pickle>
+      <global name="TALESMethod" module="Products.Formulator.TALESField"/>
+    </pickle>
+    <pickle>
+      <dictionary>
+        <item>
+            <key> <string>_text</string> </key>
+            <value> <string encoding="cdata"><![CDATA[
+
+python:"<h1>%s</h1>" % (context.Base_translateString(context.getDescription()))
+
+]]></string> </value>
+        </item>
+      </dictionary>
+    </pickle>
+  </record>
+</ZopeData>
diff --git a/master/bt5/vifib_web/SkinTemplateItem/portal_skins/vifib_hosting/WebSection_viewServiceChoiceDialog/your_computer.xml b/master/bt5/vifib_web/SkinTemplateItem/portal_skins/vifib_hosting/WebSection_viewInstanceParameterDialog/your_computer.xml
similarity index 100%
rename from master/bt5/vifib_web/SkinTemplateItem/portal_skins/vifib_hosting/WebSection_viewServiceChoiceDialog/your_computer.xml
rename to master/bt5/vifib_web/SkinTemplateItem/portal_skins/vifib_hosting/WebSection_viewInstanceParameterDialog/your_computer.xml
diff --git a/master/bt5/vifib_web/SkinTemplateItem/portal_skins/vifib_hosting/WebSection_viewServiceChoiceDialog/your_instance_xml.xml b/master/bt5/vifib_web/SkinTemplateItem/portal_skins/vifib_hosting/WebSection_viewInstanceParameterDialog/your_instance_xml.xml
similarity index 100%
rename from master/bt5/vifib_web/SkinTemplateItem/portal_skins/vifib_hosting/WebSection_viewServiceChoiceDialog/your_instance_xml.xml
rename to master/bt5/vifib_web/SkinTemplateItem/portal_skins/vifib_hosting/WebSection_viewInstanceParameterDialog/your_instance_xml.xml
diff --git a/master/bt5/vifib_web/SkinTemplateItem/portal_skins/vifib_hosting/WebSection_viewServiceChoiceDialog/your_service_title.xml b/master/bt5/vifib_web/SkinTemplateItem/portal_skins/vifib_hosting/WebSection_viewInstanceParameterDialog/your_service_title.xml
similarity index 94%
rename from master/bt5/vifib_web/SkinTemplateItem/portal_skins/vifib_hosting/WebSection_viewServiceChoiceDialog/your_service_title.xml
rename to master/bt5/vifib_web/SkinTemplateItem/portal_skins/vifib_hosting/WebSection_viewInstanceParameterDialog/your_service_title.xml
index 542ea1dd7..2b4ee0517 100644
--- a/master/bt5/vifib_web/SkinTemplateItem/portal_skins/vifib_hosting/WebSection_viewServiceChoiceDialog/your_service_title.xml
+++ b/master/bt5/vifib_web/SkinTemplateItem/portal_skins/vifib_hosting/WebSection_viewInstanceParameterDialog/your_service_title.xml
@@ -118,7 +118,9 @@
                 </item>
                 <item>
                     <key> <string>default</string> </key>
-                    <value> <string></string> </value>
+                    <value>
+                      <persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
+                    </value>
                 </item>
                 <item>
                     <key> <string>description</string> </key>
@@ -257,4 +259,17 @@
       </dictionary>
     </pickle>
   </record>
+  <record id="2" aka="AAAAAAAAAAI=">
+    <pickle>
+      <global name="TALESMethod" module="Products.Formulator.TALESField"/>
+    </pickle>
+    <pickle>
+      <dictionary>
+        <item>
+            <key> <string>_text</string> </key>
+            <value> <string>python: "Instance %i" % DateTime().millis()</string> </value>
+        </item>
+      </dictionary>
+    </pickle>
+  </record>
 </ZopeData>
diff --git a/master/bt5/vifib_web/SkinTemplateItem/portal_skins/vifib_hosting/WebSection_viewServiceChoiceDialog/your_shared.xml b/master/bt5/vifib_web/SkinTemplateItem/portal_skins/vifib_hosting/WebSection_viewInstanceParameterDialog/your_shared.xml
similarity index 99%
rename from master/bt5/vifib_web/SkinTemplateItem/portal_skins/vifib_hosting/WebSection_viewServiceChoiceDialog/your_shared.xml
rename to master/bt5/vifib_web/SkinTemplateItem/portal_skins/vifib_hosting/WebSection_viewInstanceParameterDialog/your_shared.xml
index b4a69b4cb..c8b3bb7d0 100644
--- a/master/bt5/vifib_web/SkinTemplateItem/portal_skins/vifib_hosting/WebSection_viewServiceChoiceDialog/your_shared.xml
+++ b/master/bt5/vifib_web/SkinTemplateItem/portal_skins/vifib_hosting/WebSection_viewInstanceParameterDialog/your_shared.xml
@@ -8,7 +8,7 @@
       <dictionary>
         <item>
             <key> <string>id</string> </key>
-            <value> <string>your_slave</string> </value>
+            <value> <string>your_shared</string> </value>
         </item>
         <item>
             <key> <string>message_values</string> </key>
diff --git a/master/bt5/vifib_web/SkinTemplateItem/portal_skins/vifib_hosting/WebSection_viewServiceChoiceDialog.xml b/master/bt5/vifib_web/SkinTemplateItem/portal_skins/vifib_hosting/WebSection_viewServiceChoiceDialog.xml
index 0ef0f783a..e204c5229 100644
--- a/master/bt5/vifib_web/SkinTemplateItem/portal_skins/vifib_hosting/WebSection_viewServiceChoiceDialog.xml
+++ b/master/bt5/vifib_web/SkinTemplateItem/portal_skins/vifib_hosting/WebSection_viewServiceChoiceDialog.xml
@@ -99,10 +99,6 @@
                     <value>
                       <list>
                         <string>my_description</string>
-                        <string>your_service_title</string>
-                        <string>your_instance_xml</string>
-                        <string>your_computer</string>
-                        <string>your_shared</string>
                       </list>
                     </value>
                 </item>
diff --git a/master/bt5/vifib_web/bt/revision b/master/bt5/vifib_web/bt/revision
index 13ef0a79b..a21cae364 100644
--- a/master/bt5/vifib_web/bt/revision
+++ b/master/bt5/vifib_web/bt/revision
@@ -1 +1 @@
-453
\ No newline at end of file
+454
\ No newline at end of file
-- 
2.30.9