Commit a45c8b47 authored by Gabriel Monnerat's avatar Gabriel Monnerat

refactor and rename python script

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@44165 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent eaf3972b
...@@ -52,10 +52,16 @@ ...@@ -52,10 +52,16 @@
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string>import json\n <value> <string>import json\n
\n \n
kw.update(context.REQUEST.form)\n
\n
if not kw:\n
return json.dumps(dict(response=False))\n
\n
portal = context.getPortalObject()\n portal = context.getPortalObject()\n
person = portal.portal_catalog.getResultValue(portal_type="Person",\n person = portal.portal_catalog.getResultValue(portal_type="Person",\n
validation_state="validated",\n validation_state="validated",\n
**kw)\n **kw)\n
\n
return json.dumps(dict(response=(person is not None)))\n return json.dumps(dict(response=(person is not None)))\n
</string> </value> </string> </value>
</item> </item>
...@@ -73,7 +79,7 @@ return json.dumps(dict(response=(person is not None)))\n ...@@ -73,7 +79,7 @@ return json.dumps(dict(response=(person is not None)))\n
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>ERP5Site_getUserValidationState</string> </value> <value> <string>ERP5Site_checkIfUserExist</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
...@@ -136,7 +136,7 @@ ...@@ -136,7 +136,7 @@
<dictionary> <dictionary>
<item> <item>
<key> <string>_text</string> </key> <key> <string>_text</string> </key>
<value> <string>python: cell.getModificationDate()</string> </value> <value> <string>cell/getModificationDate</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
...@@ -114,14 +114,14 @@ function changeCheckBoxValue(value){\n ...@@ -114,14 +114,14 @@ function changeCheckBoxValue(value){\n
}\n }\n
\n \n
function waitCreateUNGUser(paramStr){\n function waitCreateUNGUser(paramStr){\n
$.get("ERP5Site_getUserValidationState?" + paramStr, {}, function(data, textStatus, XMLHttpRequest){\n $.get("ERP5Site_checkIfUserExist?" + paramStr, {}, function(data, textStatus, xhr){\n
data = jQuery.parseJSON(data);\n data = jQuery.parseJSON(data);\n
if (data.response == true){\n if (data.response == true){\n
clearTimeout();\n clearTimeout();\n
window.location.reload();\n window.location.reload();\n
}\n }\n
else {\n else {\n
setTimeout(waitCreateUNGUser(paramStr), 2000);\n setTimeout(waitCreateUNGUser(paramStr), 3500);\n
}\n }\n
});\n });\n
}\n }\n
...@@ -160,8 +160,7 @@ function displayLoginForm(){ \n ...@@ -160,8 +160,7 @@ function displayLoginForm(){ \n
return false;\n return false;\n
}\n }\n
else {\n else {\n
var paramStr = "first_name=" + formHash.firstname +\n var paramStr = "reference=" + formHash.login_name;\n
"&" + "last_name=" + formHash.lastname;\n
setTimeout(waitCreateUNGUser(paramStr), 2000); \n setTimeout(waitCreateUNGUser(paramStr), 2000); \n
}\n }\n
});\n });\n
......
...@@ -298,8 +298,8 @@ class TestUNG(ERP5TypeTestCase): ...@@ -298,8 +298,8 @@ class TestUNG(ERP5TypeTestCase):
response = json.loads(self.portal.ERPSite_createUNGUser()) response = json.loads(self.portal.ERPSite_createUNGUser())
self.assertEquals(response, None) self.assertEquals(response, None)
def testERP5Site_getUserValidationState(self): def testERP5Site_checkIfUserExist(self):
"""Test script ERP5Site_getUserValidationState""" """Test script ERP5Site_checkIfUserExist"""
portal = self.portal portal = self.portal
form_dict = dict(firstname="UNG", form_dict = dict(firstname="UNG",
lastname="User", lastname="User",
...@@ -311,15 +311,15 @@ class TestUNG(ERP5TypeTestCase): ...@@ -311,15 +311,15 @@ class TestUNG(ERP5TypeTestCase):
last_name=form_dict["lastname"], last_name=form_dict["lastname"],
reference=form_dict["login_name"], reference=form_dict["login_name"],
) )
response = json.loads(portal.ERP5Site_getUserValidationState(**kw)) response = json.loads(portal.ERP5Site_checkIfUserExist(**kw))
self.assertEquals(response.get("response"), False) self.assertEquals(response.get("response"), False)
self.stepTic() self.stepTic()
response = json.loads(portal.ERP5Site_getUserValidationState(**kw)) response = json.loads(portal.ERP5Site_checkIfUserExist(**kw))
self.assertEquals(response.get("response"), True) self.assertEquals(response.get("response"), True)
kw = dict(first_name="Not Exist", kw = dict(first_name="Not Exist",
reference="no_reference", reference="no_reference",
) )
response = json.loads(portal.ERP5Site_getUserValidationState(**kw)) response = json.loads(portal.ERP5Site_checkIfUserExist(**kw))
self.assertEquals(response.get("response"), False) self.assertEquals(response.get("response"), False)
self.login("ung_reference") self.login("ung_reference")
user = portal.ERP5Site_getAuthenticatedMemberPersonValue() user = portal.ERP5Site_getAuthenticatedMemberPersonValue()
......
282 283
\ No newline at end of file \ No newline at end of file
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