Commit 9af80110 authored by Gabriel Monnerat's avatar Gabriel Monnerat

- Add new input to email

- Add script to create new user in UNG
- refactor javascript code to send POST to ERPSite_createUNGUser

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@43920 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 5bb90cf4
...@@ -55,7 +55,7 @@ ...@@ -55,7 +55,7 @@
XXX - This script should be splitted, because have many different\n XXX - This script should be splitted, because have many different\n
features(i.e add, remove and update events)\n features(i.e add, remove and update events)\n
"""\n """\n
from Products.ERP5Type.JSONEncoder import encodeInJson as dumps\n from json import dumps\n
from DateTime import DateTime\n from DateTime import DateTime\n
import random\n import random\n
\n \n
...@@ -64,6 +64,9 @@ def convertToERP5DateTime(date):\n ...@@ -64,6 +64,9 @@ def convertToERP5DateTime(date):\n
month, day, year = date.split("/")\n month, day, year = date.split("/")\n
return DateTime("%s/%s/%s %s" % (month, day, year, hour))\n return DateTime("%s/%s/%s %s" % (month, day, year, hour))\n
\n \n
if context.portal_membership.isAnonymousUser():\n
return dumps(dict(events=[]))\n
\n
portal = context.getPortalObject()\n portal = context.getPortalObject()\n
form = context.REQUEST.form\n form = context.REQUEST.form\n
portal_type_list = ["Acknowledgement",\n portal_type_list = ["Acknowledgement",\n
......
<?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>import json\n
\n
form = context.REQUEST.form\n
portal = context.getPortalObject()\n
\n
person = portal.person_module.newContent(portal_type="Person")\n
person.edit(first_name=form.get("firstname"),\n
last_name=form.get("lastname"),\n
password=form.get("password"))\n
\n
assignment = person.newContent(portal_type=\'Assignment\')\n
assignment.setFunction("function/ung_user")\n
assignment.open()\n
\n
person.validate()\n
\n
return json.dumps(True)\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>_proxy_roles</string> </key>
<value>
<tuple>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>ERPSite_createUNGUser</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -78,14 +78,17 @@ ...@@ -78,14 +78,17 @@
<tbody>\n <tbody>\n
<tr>\n <tr>\n
<td>\n <td>\n
<form id="create-user" method="post">\n
<table width="100%">\n <table width="100%">\n
<tr><td>First name:</td><td><input type="text" name="firstname"/></td></tr>\n <tr><td>First name:</td><td><input type="text" name="firstname"/></td></tr>\n
<tr><td>Last name:</td><td><input type="text" name="lastname"/></td></tr>\n <tr><td>Last name:</td><td><input type="text" name="lastname"/></td></tr>\n
<tr><td>Email:</td><td><input type="text" name="email"/></td></tr>\n
<tr><td>Login name:</td><td><input type="text" name="login"/></td></tr>\n <tr><td>Login name:</td><td><input type="text" name="login"/></td></tr>\n
<tr><td>Password:</td><td><input type="password" name="password"/></td></tr>\n <tr><td>Password:</td><td><input type="password" name="password"/></td></tr>\n
<tr><td>Confirm Password:</td><td><input type="password" name="confirm"/></td></tr>\n <tr><td>Confirm Password:</td><td><input type="password" name="confirm"/></td></tr>\n
<td align="center" colspan="2"><input type="submit" name="logged_in:method" class="submit" value="Create Account"></td>\n <td align="center" colspan="2"><input type="submit" name="logged_in:method" class="submit" value="Create Account"></td>\n
</table>\n </table>\n
</form>\n
</td>\n </td>\n
</tr>\n </tr>\n
</tbody>\n </tbody>\n
......
...@@ -112,6 +112,15 @@ function displayLoginForm(){\n ...@@ -112,6 +112,15 @@ function displayLoginForm(){\n
$("td#new-account-form").click(function(event){\n $("td#new-account-form").click(function(event){\n
$("table#field_table, table#new-account-table").hide();\n $("table#field_table, table#new-account-table").hide();\n
$("table#create-new-user").show();\n $("table#create-new-user").show();\n
$("form#create-user").submit(function(event){\n
event.preventDefault();\n
$.ajax({\n
type: \'post\',\n
url: \'ERPSite_createUNGUser\',\n
data: $("form#create-user").serializeArray(),\n
dataType: "json",\n
});\n
});\n
});\n });\n
});\n });\n
}\n }\n
......
...@@ -161,14 +161,15 @@ class TestUNG(ERP5TypeTestCase): ...@@ -161,14 +161,15 @@ class TestUNG(ERP5TypeTestCase):
self.login("ung_new_user") self.login("ung_new_user")
self.portal.WebSection_userFollowUpWebPage("new.Web-Page") self.portal.WebSection_userFollowUpWebPage("new.Web-Page")
self.stepTic() self.stepTic()
self.assertEquals(["person_module/1"], web_page.getFollowUpList()) self.login("ERP5TypeTestCase")
self.stepTic() self.assertEquals("ung_new_user", web_page.getFollowUpValue().getReference())
self.login("ung_new_user2") self.login("ung_new_user2")
self.portal.WebSection_userFollowUpWebPage("new.Web-Page") self.portal.WebSection_userFollowUpWebPage("new.Web-Page")
self.stepTic() self.stepTic()
followup_list = web_page.getFollowUpList() self.login("ERP5TypeTestCase")
self.assertEquals(["person_module/1", "person_module/2"], reference_list = [user.getReference() for user in web_page.getFollowUpValueList()]
sorted(followup_list)) self.assertEquals(["ung_new_user", "ung_new_user2"],
sorted(reference_list))
def testWebSection_getGadgetPathList(self): def testWebSection_getGadgetPathList(self):
"""Validate the gadget list""" """Validate the gadget list"""
...@@ -270,3 +271,16 @@ class TestUNG(ERP5TypeTestCase): ...@@ -270,3 +271,16 @@ class TestUNG(ERP5TypeTestCase):
self.stepTic() self.stepTic()
web_message = self.portal.portal_catalog.getResultValue(portal_type="Web Message") web_message = self.portal.portal_catalog.getResultValue(portal_type="Web Message")
self.assertEquals(web_message, None) self.assertEquals(web_message, None)
def testERPSite_createUNGUser(self):
"""Test if script creates an user correctly"""
form_dict = dict(firstname="UNG",
lastname="User",
password="ung_password")
self.portal.REQUEST.form.update(form_dict)
self.portal.ERPSite_createUNGUser()
self.stepTic()
person = self.portal.portal_catalog.getResultValue(portal_type="Person",
first_name="UNG")
self.assertEquals(person.getLastName(), "User")
self.assertEquals(person.getValidationState(), "validated")
\ No newline at end of file
266 267
\ 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