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 @@
XXX - This script should be splitted, because have many different\n
features(i.e add, remove and update events)\n
"""\n
from Products.ERP5Type.JSONEncoder import encodeInJson as dumps\n
from json import dumps\n
from DateTime import DateTime\n
import random\n
\n
......@@ -64,6 +64,9 @@ def convertToERP5DateTime(date):\n
month, day, year = date.split("/")\n
return DateTime("%s/%s/%s %s" % (month, day, year, hour))\n
\n
if context.portal_membership.isAnonymousUser():\n
return dumps(dict(events=[]))\n
\n
portal = context.getPortalObject()\n
form = context.REQUEST.form\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 @@
<tbody>\n
<tr>\n
<td>\n
<form id="create-user" method="post">\n
<table width="100%">\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>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>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
<td align="center" colspan="2"><input type="submit" name="logged_in:method" class="submit" value="Create Account"></td>\n
</table>\n
</form>\n
</td>\n
</tr>\n
</tbody>\n
......
......@@ -112,6 +112,15 @@ function displayLoginForm(){\n
$("td#new-account-form").click(function(event){\n
$("table#field_table, table#new-account-table").hide();\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
......
......@@ -161,14 +161,15 @@ class TestUNG(ERP5TypeTestCase):
self.login("ung_new_user")
self.portal.WebSection_userFollowUpWebPage("new.Web-Page")
self.stepTic()
self.assertEquals(["person_module/1"], web_page.getFollowUpList())
self.stepTic()
self.login("ERP5TypeTestCase")
self.assertEquals("ung_new_user", web_page.getFollowUpValue().getReference())
self.login("ung_new_user2")
self.portal.WebSection_userFollowUpWebPage("new.Web-Page")
self.stepTic()
followup_list = web_page.getFollowUpList()
self.assertEquals(["person_module/1", "person_module/2"],
sorted(followup_list))
self.login("ERP5TypeTestCase")
reference_list = [user.getReference() for user in web_page.getFollowUpValueList()]
self.assertEquals(["ung_new_user", "ung_new_user2"],
sorted(reference_list))
def testWebSection_getGadgetPathList(self):
"""Validate the gadget list"""
......@@ -270,3 +271,16 @@ class TestUNG(ERP5TypeTestCase):
self.stepTic()
web_message = self.portal.portal_catalog.getResultValue(portal_type="Web Message")
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
\ No newline at end of file
267
\ 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