Commit 75e5507b authored by Ivan Tyagov's avatar Ivan Tyagov

refactor Web Site user creation form and script.

Add own validator for match of password and confirm password fields.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@15059 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 7ab3cde0
......@@ -90,7 +90,7 @@ except (FormValidationError, ValidationError,), validation_errors:\n
return form()\n
\n
# extract only user details\n
kw = context.REQUEST.form\n
kw = context.REQUEST\n
filtered_kw = {}\n
prefix = \'field_your_\'\n
for key in kw.keys():\n
......@@ -107,6 +107,8 @@ person_role = \'internal\'\n
person_module = context.getPortalObject().person_module\n
person = person_module.newContent(portal_type = \'Person\', \n
**filtered_kw)\n
person.validate()\n
person.immediateReindexObject()\n
\n
# create default career\n
career = person.newContent(portal_type = \'Career\', \n
......@@ -119,8 +121,7 @@ assignment = person.newContent(portal_type = \'Assignment\', \n
group = person_group, \n
function = person_function, \n
site = person_site)\n
# submit it for review\n
person.submit()\n
assignment.open()\n
\n
translateString = context.Base_translateString\n
msg = translateString("Your account was successfully created.")\n
......@@ -155,7 +156,9 @@ return website.Base_redirect(\'view\', \n
<item>
<key> <string>_proxy_roles</string> </key>
<value>
<tuple/>
<tuple>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
......
......@@ -105,7 +105,7 @@
<string>your_default_address_region</string>
<string>your_reference</string>
<string>your_password</string>
<string>password_confirm</string>
<string>your_password_confirm</string>
<string>submit</string>
</list>
</value>
......
......@@ -279,7 +279,7 @@
<dictionary>
<item>
<key> <string>method_name</string> </key>
<value> <string>Person_validatePasswordsMatch</string> </value>
<value> <string>WebSite_validatePasswordsMatch</string> </value>
</item>
</dictionary>
</pickle>
......
......@@ -14,7 +14,7 @@
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>password_confirm</string> </value>
<value> <string>your_password_confirm</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
......@@ -279,7 +279,7 @@
<dictionary>
<item>
<key> <string>method_name</string> </key>
<value> <string>Person_validatePasswordsMatch</string> </value>
<value> <string>WebSite_validatePasswordsMatch</string> </value>
</item>
</dictionary>
</pickle>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<tuple>
<string>Products.PythonScripts.PythonScript</string>
<string>PythonScript</string>
</tuple>
<none/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Python_magic</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>__ac_local_roles__</string> </key>
<value>
<none/>
</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>"""\n
External Validator for WebSite_createWebSiteAccountForm/your_password\n
that checks that password and password confimation matches.\n
"""\n
password_confirm = request.get(\'field_your_password_confirm\', request.get(\'password_confirm\'))\n
if password_confirm == editor:\n
return 1\n
return 0\n
</string> </value>
</item>
<item>
<key> <string>_code</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_filepath</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_owner</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>editor, request</string> </value>
</item>
<item>
<key> <string>errors</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>func_code</string> </key>
<value>
<object>
<klass>
<global name="FuncCode" module="Shared.DC.Scripts.Signature"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>co_argcount</string> </key>
<value> <int>2</int> </value>
</item>
<item>
<key> <string>co_varnames</string> </key>
<value>
<tuple>
<string>editor</string>
<string>request</string>
<string>_getattr_</string>
<string>password_confirm</string>
</tuple>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>func_defaults</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>WebSite_validatePasswordsMatch</string> </value>
</item>
<item>
<key> <string>warnings</string> </key>
<value>
<tuple/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
562
\ No newline at end of file
567
\ 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