[Erp5-report] r38436 fx.algrain - /experimental/bt5/erp5_credential/SkinTemplateItem/portal...

nobody at svn.erp5.org nobody at svn.erp5.org
Fri Sep 17 09:00:16 CEST 2010


Author: fx.algrain
Date: Fri Sep 17 09:00:14 2010
New Revision: 38436

URL: http://svn.erp5.org?rev=38436&view=rev
Log:
Use property to construct the list for mapping.
Add docstring on Credential_copyRegistredInformation.
You can now decide too keep empty values on destination

Modified:
    experimental/bt5/erp5_credential/SkinTemplateItem/portal_skins/erp5_credential/CredentialRequest_setRegisteredInformationToOrganisation.xml
    experimental/bt5/erp5_credential/SkinTemplateItem/portal_skins/erp5_credential/CredentialRequest_setRegisteredInformationToPerson.xml
    experimental/bt5/erp5_credential/SkinTemplateItem/portal_skins/erp5_credential/Credential_copyRegistredInformation.xml

Modified: experimental/bt5/erp5_credential/SkinTemplateItem/portal_skins/erp5_credential/CredentialRequest_setRegisteredInformationToOrganisation.xml
URL: http://svn.erp5.org/experimental/bt5/erp5_credential/SkinTemplateItem/portal_skins/erp5_credential/CredentialRequest_setRegisteredInformationToOrganisation.xml?rev=38436&r1=38435&r2=38436&view=diff
==============================================================================
--- experimental/bt5/erp5_credential/SkinTemplateItem/portal_skins/erp5_credential/CredentialRequest_setRegisteredInformationToOrganisation.xml [utf8] (original)
+++ experimental/bt5/erp5_credential/SkinTemplateItem/portal_skins/erp5_credential/CredentialRequest_setRegisteredInformationToOrganisation.xml [utf8] Fri Sep 17 09:00:14 2010
@@ -52,17 +52,17 @@
             <key> <string>_body</string> </key>
             <value> <string>"""Copy subscription information to related person"""\n
 \n
-context.CredentialRequest_checkConsistency([\'Organisation\'])\n
+context.Credential_checkConsistency([\'Organisation\'])\n
 organisation = context.getDestinationDecisionValue(portal_type="Organisation")\n
 person = context.getDestinationDecisionValue(portal_type="Person")\n
 \n
 #Mapping\n
 organisation_mapping = (\n
     # (subscription, organisation)\n
-    (\'CorporateName\', \'Title\'),\n
+    (\'corporate_name\', \'title\'),\n
     )\n
 \n
-context.CredentialRequest_copyRegistredInformation(organisation, organisation_mapping)\n
+context.Credential_copyRegistredInformation(organisation, organisation_mapping)\n
 \n
 #Attach the organisation to the person if we have a person\n
 if person:\n

Modified: experimental/bt5/erp5_credential/SkinTemplateItem/portal_skins/erp5_credential/CredentialRequest_setRegisteredInformationToPerson.xml
URL: http://svn.erp5.org/experimental/bt5/erp5_credential/SkinTemplateItem/portal_skins/erp5_credential/CredentialRequest_setRegisteredInformationToPerson.xml?rev=38436&r1=38435&r2=38436&view=diff
==============================================================================
--- experimental/bt5/erp5_credential/SkinTemplateItem/portal_skins/erp5_credential/CredentialRequest_setRegisteredInformationToPerson.xml [utf8] (original)
+++ experimental/bt5/erp5_credential/SkinTemplateItem/portal_skins/erp5_credential/CredentialRequest_setRegisteredInformationToPerson.xml [utf8] Fri Sep 17 09:00:14 2010
@@ -52,33 +52,35 @@
             <key> <string>_body</string> </key>
             <value> <string>"""Copy subscription information to related person"""\n
 \n
-context.CredentialRequest_checkConsistency([\'Person\'])\n
+context.Credential_checkConsistency([\'Person\'])\n
+person = context.getDestinationDecisionValue(portal_type="Person")\n
 \n
 # Person Mapping\n
 person_mapping = (\n
     # (subscription, person)\n
-    (\'FirstName\', \'FirstName\'),\n
-    (\'LastName\', \'LastName\'),\n
-    (\'DefaultEmailText\', \'DefaultEmailText\'),\n
-    (\'DefaultTelephoneText\', \'DefaultTelephoneText\'),\n
-    (\'DefaultFaxText\', \'DefaultFaxText\'),\n
-    (\'DefaultAddressStreetAddress\', \'DefaultAddressStreetAddress\'),\n
-    (\'DefaultAddressZipCode\', \'DefaultAddressZipCode\'),\n
-    (\'DefaultAddressCity\', \'DefaultAddressCity\'),\n
-    (\'DefaultAddressRegion\', \'DefaultAddressRegion\'),\n
-    (\'DefaultMobileTelephoneText\', \'DefaultMobileTelephoneText\'),\n
-    (\'ActivityList\', \'DefaultCareerActivityList\'),\n
-    (\'FunctionList\', \'DefaultCareerFunctionList\'),\n
-    (\'RoleList\', \'DefaultCareerRoleList\'),\n
-    (\'DefaultCredentialQuestionAnswer\', \'DefaultCredentialQuestionAnswer\'),\n
-    (\'DefaultCredentialQuestionQuestion\', \'DefaultCredentialQuestionQuestion\'),\n
-    (\'DefaultCredentialQuestionQuestionFreeText\', \'DefaultCredentialQuestionQuestionFreeText\'),\n
+    (\'first_name\', \'first_name\'),\n
+    (\'last_name\', \'last_name\'),\n
+    (\'birthday\', \'birthday\'),\n
+    (\'default_email_text\', \'default_email_text\'),\n
+    (\'default_telephone_text\', \'default_telephone_text\'),\n
+    (\'default_fax_text\', \'default_fax_text\'),\n
+    (\'default_address_street_address\', \'default_address_street_address\'),\n
+    (\'default_address_zip_code\', \'default_address_zip_code\'),\n
+    (\'default_address_city\', \'default_address_city\'),\n
+    (\'default_address_region\', \'default_address_region\'),\n
+    (\'default_mobile_telephone_text\', \'default_mobile_telephone_text\'),\n
+    (\'activity_list\', \'default_career_activity_list\'),\n
+    (\'function_list\', \'default_career_function_list\'),\n
+    (\'role_list\', \'default_career_role_list\'),\n
+    (\'default_credential_question_answer\', \'default_credential_question_answer\'),\n
+    (\'default_credential_question_question\', \'default_credential_question_question\'),\n
+    (\'default_credential_question_question_free_text\', \'default_credential_question_question_free_text\'),\n
     )\n
 \n
-context.CredentialRequest_copyRegistredInformation(person, person_mapping)\n
+context.Credential_copyRegistredInformation(person, person_mapping)\n
 \n
 \n
-#Try to validate\n
+#try to validate\n
 \n
 try:\n
   person.validate()\n
@@ -133,8 +135,8 @@ except:\n
                           <tuple>
                             <string>_getattr_</string>
                             <string>context</string>
-                            <string>person_mapping</string>
                             <string>person</string>
+                            <string>person_mapping</string>
                           </tuple>
                         </value>
                     </item>

Modified: experimental/bt5/erp5_credential/SkinTemplateItem/portal_skins/erp5_credential/Credential_copyRegistredInformation.xml
URL: http://svn.erp5.org/experimental/bt5/erp5_credential/SkinTemplateItem/portal_skins/erp5_credential/Credential_copyRegistredInformation.xml?rev=38436&r1=38435&r2=38436&view=diff
==============================================================================
--- experimental/bt5/erp5_credential/SkinTemplateItem/portal_skins/erp5_credential/Credential_copyRegistredInformation.xml [utf8] (original)
+++ experimental/bt5/erp5_credential/SkinTemplateItem/portal_skins/erp5_credential/Credential_copyRegistredInformation.xml [utf8] Fri Sep 17 09:00:14 2010
@@ -50,7 +50,12 @@
         </item>
         <item>
             <key> <string>_body</string> </key>
-            <value> <string>"""Use a list of tuple to copy information from credential request to an object"""\n
+            <value> <string>"""Copy information from context to an object\n
+Parameters:\n
+destination -- Object where copy property value\n
+mapping -- Define property mapping (List of tuple of 2 property)\n
+copy_empty_value -- Copy or not empty value of context to destination\n
+erase_empty_value -- Erase or not empty value of destination"""\n
 def getAccessor(property):\n
   return "".join([x.capitalize() for x in property.split(\'_\')])\n
 \n
@@ -59,8 +64,11 @@ def copyValue(source_document, source_ac
     getter = getattr(source_document, \'get%s\' % source_accessor)\n
     value = getter()\n
     if not value and copy_empty_value or value:\n
-      setter = getattr(destination_document, \'set%s\' % destination_accessor)\n
-      setter(value)\n
+      old_getter = getattr(destination_document, \'get%s\' % destination_accessor)     \n
+      old_value = old_getter()\n
+      if not old_value and erase_empty_value or old_value: \n
+        setter = getattr(destination_document, \'set%s\' % destination_accessor)\n
+        setter(value)\n
 \n
 def copyDocument(source_document, destination_document, mapping):\n
     for source_property, destination_property in mapping:\n
@@ -70,7 +78,7 @@ def copyDocument(source_document, destin
 \n
 \n
 \n
-copyDocument(context, source, mapping)\n
+copyDocument(context, destination, mapping)\n
 </string> </value>
         </item>
         <item>
@@ -81,7 +89,7 @@ copyDocument(context, source, mapping)\n
         </item>
         <item>
             <key> <string>_params</string> </key>
-            <value> <string>source,mapping,copy_empty_value=True,erase_empty_value=True</string> </value>
+            <value> <string>destination,mapping,copy_empty_value=True,erase_empty_value=True</string> </value>
         </item>
         <item>
             <key> <string>errors</string> </key>
@@ -107,7 +115,7 @@ copyDocument(context, source, mapping)\n
                         <key> <string>co_varnames</string> </key>
                         <value>
                           <tuple>
-                            <string>source</string>
+                            <string>destination</string>
                             <string>mapping</string>
                             <string>copy_empty_value</string>
                             <string>erase_empty_value</string>




More information about the Erp5-report mailing list