From ecb22e5e12fd6b2015c79ae4e246f06f039d7df9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?C=C3=A9dric=20Le=20Ninivin?= <cedric.leninivin@tiolive.com>
Date: Wed, 17 Jun 2015 13:01:17 +0000
Subject: [PATCH] erp5_free_subscription: Use Emails in Free Subscription
 requests

---
 .../allowed_content_types.xml                 |   3 +
 .../property_sheet_list.xml                   |   1 +
 .../FreeSubscriptionRequest_accept.xml        |   6 +-
 .../FreeSubscriptionRequest_view.xml          |   2 +
 .../my_default_email_coordinate_text.xml      | 115 ++++++++++++++++++
 .../my_default_email_url_string.xml           | 115 ++++++++++++++++++
 ...late_portal_type_allowed_content_type_list |   3 +-
 .../template_portal_type_property_sheet_list  |   1 +
 8 files changed, 242 insertions(+), 4 deletions(-)
 create mode 100644 bt5/erp5_free_subscription/SkinTemplateItem/portal_skins/erp5_free_subscription/FreeSubscriptionRequest_view/my_default_email_coordinate_text.xml
 create mode 100644 bt5/erp5_free_subscription/SkinTemplateItem/portal_skins/erp5_free_subscription/FreeSubscriptionRequest_view/my_default_email_url_string.xml

diff --git a/bt5/erp5_free_subscription/PortalTypeAllowedContentTypeTemplateItem/allowed_content_types.xml b/bt5/erp5_free_subscription/PortalTypeAllowedContentTypeTemplateItem/allowed_content_types.xml
index 3fef6691fb..fb76c1e397 100644
--- a/bt5/erp5_free_subscription/PortalTypeAllowedContentTypeTemplateItem/allowed_content_types.xml
+++ b/bt5/erp5_free_subscription/PortalTypeAllowedContentTypeTemplateItem/allowed_content_types.xml
@@ -2,6 +2,9 @@
  <portal_type id="Free Subscription Module">
   <item>Free Subscription</item>
  </portal_type>
+ <portal_type id="Free Subscription Request">
+  <item>Email</item>
+ </portal_type>
  <portal_type id="Free Subscription Request Module">
   <item>Free Subscription Request</item>
  </portal_type>
diff --git a/bt5/erp5_free_subscription/PortalTypePropertySheetTemplateItem/property_sheet_list.xml b/bt5/erp5_free_subscription/PortalTypePropertySheetTemplateItem/property_sheet_list.xml
index d1d3272d02..60930635dd 100644
--- a/bt5/erp5_free_subscription/PortalTypePropertySheetTemplateItem/property_sheet_list.xml
+++ b/bt5/erp5_free_subscription/PortalTypePropertySheetTemplateItem/property_sheet_list.xml
@@ -7,5 +7,6 @@
   <item>Arrow</item>
   <item>DublinCore</item>
   <item>Reference</item>
+  <item>Person</item>
  </portal_type>
 </property_sheet_list>
\ No newline at end of file
diff --git a/bt5/erp5_free_subscription/SkinTemplateItem/portal_skins/erp5_free_subscription/FreeSubscriptionRequest_accept.xml b/bt5/erp5_free_subscription/SkinTemplateItem/portal_skins/erp5_free_subscription/FreeSubscriptionRequest_accept.xml
index d2ddb62ecc..44946a17c0 100644
--- a/bt5/erp5_free_subscription/SkinTemplateItem/portal_skins/erp5_free_subscription/FreeSubscriptionRequest_accept.xml
+++ b/bt5/erp5_free_subscription/SkinTemplateItem/portal_skins/erp5_free_subscription/FreeSubscriptionRequest_accept.xml
@@ -58,12 +58,12 @@ if context.getValidationState() != \'submitted\':\n
   return\n
 if context.getDestination():\n
   context.accept()\n
-elif hasattr(context, \'destination_person_default_email_text\'):\n
-  email = context.destination_person_default_email_text\n
+elif context.getDefaultEmailCoordinateText():\n
+  email = context.getDefaultEmailCoordinateText()\n
   portal = context.getPortalObject()\n
   person_list = portal.portal_catalog.getResultValue(\n
     portal_type="Person",\n
-    default_email_text=email,\n
+    reference=email,\n
     )\n
   if person_list:\n
     context.reject(comment="Person already in the user data base")\n
diff --git a/bt5/erp5_free_subscription/SkinTemplateItem/portal_skins/erp5_free_subscription/FreeSubscriptionRequest_view.xml b/bt5/erp5_free_subscription/SkinTemplateItem/portal_skins/erp5_free_subscription/FreeSubscriptionRequest_view.xml
index 9c05f62945..2fc7792dda 100644
--- a/bt5/erp5_free_subscription/SkinTemplateItem/portal_skins/erp5_free_subscription/FreeSubscriptionRequest_view.xml
+++ b/bt5/erp5_free_subscription/SkinTemplateItem/portal_skins/erp5_free_subscription/FreeSubscriptionRequest_view.xml
@@ -79,6 +79,8 @@
                         <string>my_resource_title</string>
                         <string>my_causality_title</string>
                         <string>my_follow_up_title</string>
+                        <string>my_default_email_coordinate_text</string>
+                        <string>my_default_email_url_string</string>
                       </list>
                     </value>
                 </item>
diff --git a/bt5/erp5_free_subscription/SkinTemplateItem/portal_skins/erp5_free_subscription/FreeSubscriptionRequest_view/my_default_email_coordinate_text.xml b/bt5/erp5_free_subscription/SkinTemplateItem/portal_skins/erp5_free_subscription/FreeSubscriptionRequest_view/my_default_email_coordinate_text.xml
new file mode 100644
index 0000000000..d09034c96c
--- /dev/null
+++ b/bt5/erp5_free_subscription/SkinTemplateItem/portal_skins/erp5_free_subscription/FreeSubscriptionRequest_view/my_default_email_coordinate_text.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>enabled</string>
+              </list>
+            </value>
+        </item>
+        <item>
+            <key> <string>id</string> </key>
+            <value> <string>my_default_email_coordinate_text</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>enabled</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>enabled</string> </key>
+                    <value> <int>1</int> </value>
+                </item>
+                <item>
+                    <key> <string>field_id</string> </key>
+                    <value> <string>my_email</string> </value>
+                </item>
+                <item>
+                    <key> <string>form_id</string> </key>
+                    <value> <string>Base_viewFieldLibrary</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>python: (here.hasDefaultEmail() and not here.getDefaultEmail().isDetailed()) or not here.hasDefaultEmail()</string> </value>
+        </item>
+      </dictionary>
+    </pickle>
+  </record>
+</ZopeData>
diff --git a/bt5/erp5_free_subscription/SkinTemplateItem/portal_skins/erp5_free_subscription/FreeSubscriptionRequest_view/my_default_email_url_string.xml b/bt5/erp5_free_subscription/SkinTemplateItem/portal_skins/erp5_free_subscription/FreeSubscriptionRequest_view/my_default_email_url_string.xml
new file mode 100644
index 0000000000..87bdf3cd34
--- /dev/null
+++ b/bt5/erp5_free_subscription/SkinTemplateItem/portal_skins/erp5_free_subscription/FreeSubscriptionRequest_view/my_default_email_url_string.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>enabled</string>
+              </list>
+            </value>
+        </item>
+        <item>
+            <key> <string>id</string> </key>
+            <value> <string>my_default_email_url_string</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>enabled</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>enabled</string> </key>
+                    <value> <int>1</int> </value>
+                </item>
+                <item>
+                    <key> <string>field_id</string> </key>
+                    <value> <string>my_view_mode_email_url_string</string> </value>
+                </item>
+                <item>
+                    <key> <string>form_id</string> </key>
+                    <value> <string>Base_viewBaseFieldLibrary</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>python:here.hasDefaultEmail() and here.getDefaultEmail().isDetailed()</string> </value>
+        </item>
+      </dictionary>
+    </pickle>
+  </record>
+</ZopeData>
diff --git a/bt5/erp5_free_subscription/bt/template_portal_type_allowed_content_type_list b/bt5/erp5_free_subscription/bt/template_portal_type_allowed_content_type_list
index d2d28db93b..a3fb0de112 100644
--- a/bt5/erp5_free_subscription/bt/template_portal_type_allowed_content_type_list
+++ b/bt5/erp5_free_subscription/bt/template_portal_type_allowed_content_type_list
@@ -1,2 +1,3 @@
 Free Subscription Module | Free Subscription
-Free Subscription Request Module | Free Subscription Request
\ No newline at end of file
+Free Subscription Request Module | Free Subscription Request
+Free Subscription Request | Email
\ No newline at end of file
diff --git a/bt5/erp5_free_subscription/bt/template_portal_type_property_sheet_list b/bt5/erp5_free_subscription/bt/template_portal_type_property_sheet_list
index 7c25aede8a..a792e02467 100644
--- a/bt5/erp5_free_subscription/bt/template_portal_type_property_sheet_list
+++ b/bt5/erp5_free_subscription/bt/template_portal_type_property_sheet_list
@@ -1,5 +1,6 @@
 Free Subscription Request | Arrow
 Free Subscription Request | DublinCore
 Free Subscription Request | Reference
+Free Subscription Request | Person
 Free Subscription | DublinCore
 Free Subscription | Version
\ No newline at end of file
-- 
2.30.9