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

nobody at svn.erp5.org nobody at svn.erp5.org
Fri Sep 17 15:23:55 CEST 2010


Author: fx.algrain
Date: Fri Sep 17 15:23:55 2010
New Revision: 38462

URL: http://svn.erp5.org?rev=38462&view=rev
Log:
Improve check of login :
- allow to update reference on credential request
- allow user to create credential request with it's username
- don't allow to create a request if a request exist with the same reference
- rename parameter
- use directly the value and not get if from request

Modified:
    experimental/bt5/erp5_credential/SkinTemplateItem/portal_skins/erp5_credential/CredentialRequest_checkLoginAvailability.xml
    experimental/bt5/erp5_credential/SkinTemplateItem/portal_skins/erp5_credential/CredentialRequest_checkLoginExistence.xml

Modified: experimental/bt5/erp5_credential/SkinTemplateItem/portal_skins/erp5_credential/CredentialRequest_checkLoginAvailability.xml
URL: http://svn.erp5.org/experimental/bt5/erp5_credential/SkinTemplateItem/portal_skins/erp5_credential/CredentialRequest_checkLoginAvailability.xml?rev=38462&r1=38461&r2=38462&view=diff
==============================================================================
--- experimental/bt5/erp5_credential/SkinTemplateItem/portal_skins/erp5_credential/CredentialRequest_checkLoginAvailability.xml [utf8] (original)
+++ experimental/bt5/erp5_credential/SkinTemplateItem/portal_skins/erp5_credential/CredentialRequest_checkLoginAvailability.xml [utf8] Fri Sep 17 15:23:55 2010
@@ -50,18 +50,49 @@
         </item>
         <item>
             <key> <string>_body</string> </key>
-            <value> <string>"""Check if login is avaible or not"""\n
+            <value> <string encoding="cdata"><![CDATA[
+
+"""Check if login is avaible or not.\n
+Parameters:\n
+value -- field value (string)\n
+RESQEST -- standard REQUEST variable"""\n
 \n
-from Products.DCWorkflow.DCWorkflow import ValidationFailed\n
-from Products.ERP5Type.Message import translateString\n
-reference = request.get(\'field_my_reference\', \n
-                      request.get(\'my_reference\'))\n
-if not reference:\n
-  reference = request.get(\'field_your_reference\', \n
-                      request.get(\'your_reference\'))\n
+def getRealContext():\n
+  object_path = REQUEST.get("object_path")\n
+  portal = context.getPortalObject()\n
+  return portal.restrictedTraverse(object_path)\n
 \n
-return context.ERP5Site_isLocalLoginAvailable(reference)\n
-</string> </value>
+#Allow user to create a request with it\'s username\n
+member = context.portal_membership.getAuthenticatedMember()\n
+if member is not None \\\n
+   and member.getUserName() == value \\\n
+   and value != "Anonymous User":\n
+  return True\n
+\n
+\n
+context = getRealContext()\n
+#Allow reference for person in relation with the credential request\n
+if context.getPortalType() == "Credential Request":\n
+  related_person = context.getDestinationDecisionValue(portal_type="Person")\n
+  if related_person:\n
+    if related_person.getReference() == value:\n
+      return True\n
+\n
+\n
+#check credential request with this user name\n
+#Don\'t take in case the current credential \n
+module = context.getDefaultModule("Credential Request")\n
+credential_request_count_result = module.countFolder(reference=value,\n
+                                                     uid="NOT %s" % context.getUid())\n
+\n
+if credential_request_count_result[0][0] > 0:\n
+  return False\n
+\n
+\n
+return context.ERP5Site_isLocalLoginAvailable(value)\n
+
+
+]]></string> </value>
         </item>
         <item>
             <key> <string>_code</string> </key>
@@ -71,7 +102,7 @@ return context.ERP5Site_isLocalLoginAvai
         </item>
         <item>
             <key> <string>_params</string> </key>
-            <value> <string>editor, request</string> </value>
+            <value> <string>value,REQUEST</string> </value>
         </item>
         <item>
             <key> <string>_proxy_roles</string> </key>
@@ -105,15 +136,19 @@ return context.ERP5Site_isLocalLoginAvai
                         <key> <string>co_varnames</string> </key>
                         <value>
                           <tuple>
-                            <string>editor</string>
-                            <string>request</string>
-                            <string>Products.DCWorkflow.DCWorkflow</string>
-                            <string>ValidationFailed</string>
-                            <string>Products.ERP5Type.Message</string>
-                            <string>translateString</string>
+                            <string>value</string>
+                            <string>REQUEST</string>
+                            <string>getRealContext</string>
                             <string>_getattr_</string>
-                            <string>reference</string>
                             <string>context</string>
+                            <string>member</string>
+                            <string>None</string>
+                            <string>True</string>
+                            <string>related_person</string>
+                            <string>module</string>
+                            <string>credential_request_count_result</string>
+                            <string>_getitem_</string>
+                            <string>False</string>
                           </tuple>
                         </value>
                     </item>

Modified: experimental/bt5/erp5_credential/SkinTemplateItem/portal_skins/erp5_credential/CredentialRequest_checkLoginExistence.xml
URL: http://svn.erp5.org/experimental/bt5/erp5_credential/SkinTemplateItem/portal_skins/erp5_credential/CredentialRequest_checkLoginExistence.xml?rev=38462&r1=38461&r2=38462&view=diff
==============================================================================
--- experimental/bt5/erp5_credential/SkinTemplateItem/portal_skins/erp5_credential/CredentialRequest_checkLoginExistence.xml [utf8] (original)
+++ experimental/bt5/erp5_credential/SkinTemplateItem/portal_skins/erp5_credential/CredentialRequest_checkLoginExistence.xml [utf8] Fri Sep 17 15:23:55 2010
@@ -51,7 +51,7 @@
         <item>
             <key> <string>_body</string> </key>
             <value> <string>"""Check if login exist or not. It\'s the inverse of avaibility"""\n
-return not context.ERP5Site_isLocalLoginAvailable(editor,request)\n
+return not context.ERP5Site_isLocalLoginAvailable(value,REQUEST)\n
 </string> </value>
         </item>
         <item>
@@ -62,7 +62,7 @@ return not context.ERP5Site_isLocalLogin
         </item>
         <item>
             <key> <string>_params</string> </key>
-            <value> <string>editor, request</string> </value>
+            <value> <string>value,REQUEST</string> </value>
         </item>
         <item>
             <key> <string>_proxy_roles</string> </key>
@@ -96,8 +96,8 @@ return not context.ERP5Site_isLocalLogin
                         <key> <string>co_varnames</string> </key>
                         <value>
                           <tuple>
-                            <string>editor</string>
-                            <string>request</string>
+                            <string>value</string>
+                            <string>REQUEST</string>
                             <string>_getattr_</string>
                             <string>context</string>
                           </tuple>




More information about the Erp5-report mailing list