Commit 62e9d1e6 authored by Jean-Paul Smets's avatar Jean-Paul Smets

Initial proxyfication of registration dialog. Use of Base_edit silent mode in...

Initial proxyfication of registration dialog. Use of Base_edit silent mode in order to use Formulator features yet prevent duplicating code

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@18875 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 954bb69e
...@@ -3,11 +3,8 @@ ...@@ -3,11 +3,8 @@
<record id="1" aka="AAAAAAAAAAE="> <record id="1" aka="AAAAAAAAAAE=">
<pickle> <pickle>
<tuple> <tuple>
<tuple> <global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
<string>Products.PythonScripts.PythonScript</string> <tuple/>
<string>PythonScript</string>
</tuple>
<none/>
</tuple> </tuple>
</pickle> </pickle>
<pickle> <pickle>
...@@ -71,7 +68,7 @@ ...@@ -71,7 +68,7 @@
<value> <string>"""\n <value> <string>"""\n
This script is a sample script skeleton (part of erp5_web)\n This script is a sample script skeleton (part of erp5_web)\n
which can be used to create user (Person object) \n which can be used to create user (Person object) \n
\n \n
Notes:\n Notes:\n
- the script is normally executed by anonymous user with Manager proxy roles which \n - the script is normally executed by anonymous user with Manager proxy roles which \n
you have to turn on after adjusting this script to your needs.\n you have to turn on after adjusting this script to your needs.\n
...@@ -81,45 +78,38 @@ ...@@ -81,45 +78,38 @@
"""\n """\n
from Products.Formulator.Errors import ValidationError, FormValidationError\n from Products.Formulator.Errors import ValidationError, FormValidationError\n
\n \n
# validate form manually\n # Call Base_edit\n
form = context.WebSite_viewRegistrationDialog\n result, result_type = context.Base_edit(form_id, silent_mode=1, field_prefix=\'your_\')\n
try:\n \n
form.validate_all_to_request(context.REQUEST)\n # Return if not appropriate\n
except (FormValidationError, ValidationError,), validation_errors:\n if result_type != \'edit\':\n
context.REQUEST.set(\'field_errors\', form.ErrorFields(validation_errors)) \n return result\n
return form()\n kw, encapsulated_editor_list = result\n
\n \n
# extract only user details\n # Set default values\n
kw = context.REQUEST\n person_group = kw.get(\'group\', \'\')\n
filtered_kw = {}\n person_function = kw.get(\'function\', \'\')\n
prefix = \'field_your_\'\n person_site = kw.get(\'site\', \'\')\n
for key in kw.keys():\n person_role = kw.get(\'role\', \'\')\n
if key.startswith(prefix):\n kw.setdefault(\'reference\', kw[\'default_email_text\'])\n
filtered_kw[key.replace(prefix, \'\')] = kw[key]\n
\n
# adjust to your needs\n
person_group = \'\'\n
person_function = \'\'\n
person_site = \'\'\n
person_role = \'internal\'\n
\n \n
# create Person account\n # create Person account\n
person_module = context.getPortalObject().person_module\n person_module = context.getPortalObject().person_module\n
person = person_module.newContent(portal_type = \'Person\', \n person = person_module.newContent(portal_type = \'Person\', \n
**filtered_kw)\n **kw)\n
person.validate()\n person.validate()\n
person.immediateReindexObject()\n person.immediateReindexObject()\n
\n \n
# create default career\n # Create default career\n
career = person.newContent(portal_type = \'Career\', \n career = person.newContent(portal_type = \'Career\',\n
id = \'default_career\', \n id = \'default_career\',\n
group = person_group, \n group = person_group,\n
function = person_function,\n function = person_function,\n
role = person_role)\n role = person_role)\n
# create assignment\n # Create assignment\n
assignment = person.newContent(portal_type = \'Assignment\', \n assignment = person.newContent(portal_type = \'Assignment\',\n
group = person_group, \n group = person_group,\n
function = person_function, \n function = person_function,\n
site = person_site)\n site = person_site)\n
assignment.open()\n assignment.open()\n
\n \n
...@@ -151,7 +141,7 @@ return website.Base_redirect(\'view\', \n ...@@ -151,7 +141,7 @@ return website.Base_redirect(\'view\', \n
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string></string> </value> <value> <string>form_id</string> </value>
</item> </item>
<item> <item>
<key> <string>_proxy_roles</string> </key> <key> <string>_proxy_roles</string> </key>
...@@ -179,30 +169,28 @@ return website.Base_redirect(\'view\', \n ...@@ -179,30 +169,28 @@ return website.Base_redirect(\'view\', \n
<dictionary> <dictionary>
<item> <item>
<key> <string>co_argcount</string> </key> <key> <string>co_argcount</string> </key>
<value> <int>0</int> </value> <value> <int>1</int> </value>
</item> </item>
<item> <item>
<key> <string>co_varnames</string> </key> <key> <string>co_varnames</string> </key>
<value> <value>
<tuple> <tuple>
<string>form_id</string>
<string>Products.Formulator.Errors</string> <string>Products.Formulator.Errors</string>
<string>ValidationError</string> <string>ValidationError</string>
<string>FormValidationError</string> <string>FormValidationError</string>
<string>_getattr_</string> <string>_getattr_</string>
<string>context</string> <string>context</string>
<string>form</string>
<string>validation_errors</string>
<string>kw</string>
<string>filtered_kw</string>
<string>prefix</string>
<string>_getiter_</string> <string>_getiter_</string>
<string>key</string> <string>result</string>
<string>_getitem_</string> <string>result_type</string>
<string>_write_</string> <string>kw</string>
<string>encapsulated_editor_list</string>
<string>person_group</string> <string>person_group</string>
<string>person_function</string> <string>person_function</string>
<string>person_site</string> <string>person_site</string>
<string>person_role</string> <string>person_role</string>
<string>_getitem_</string>
<string>person_module</string> <string>person_module</string>
<string>_apply_</string> <string>_apply_</string>
<string>person</string> <string>person</string>
......
...@@ -3,11 +3,8 @@ ...@@ -3,11 +3,8 @@
<record id="1" aka="AAAAAAAAAAE="> <record id="1" aka="AAAAAAAAAAE=">
<pickle> <pickle>
<tuple> <tuple>
<tuple> <global name="ERP5Form" module="Products.ERP5Form.Form"/>
<string>Products.ERP5Form.Form</string> <tuple/>
<string>ERP5Form</string>
</tuple>
<none/>
</tuple> </tuple>
</pickle> </pickle>
<pickle> <pickle>
...@@ -67,10 +64,8 @@ ...@@ -67,10 +64,8 @@
<key> <string>group_list</string> </key> <key> <string>group_list</string> </key>
<value> <value>
<list> <list>
<string>left</string> <string>left (User Login)</string>
<string>right</string> <string>right (User Identity)</string>
<string>center</string>
<string>bottom</string>
</list> </list>
</value> </value>
</item> </item>
...@@ -79,19 +74,17 @@ ...@@ -79,19 +74,17 @@
<value> <value>
<dictionary> <dictionary>
<item> <item>
<key> <string>bottom</string> </key> <key> <string>left (User Login)</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>center</string> </key>
<value> <value>
<list/> <list>
<string>your_reference</string>
<string>your_password</string>
<string>your_password_confirm</string>
</list>
</value> </value>
</item> </item>
<item> <item>
<key> <string>left</string> </key> <key> <string>right (User Identity)</string> </key>
<value> <value>
<list> <list>
<string>your_first_name</string> <string>your_first_name</string>
...@@ -103,19 +96,10 @@ ...@@ -103,19 +96,10 @@
<string>your_default_address_city</string> <string>your_default_address_city</string>
<string>your_default_address_zip_code</string> <string>your_default_address_zip_code</string>
<string>your_default_address_region</string> <string>your_default_address_region</string>
<string>your_reference</string>
<string>your_password</string>
<string>your_password_confirm</string>
<string>submit</string> <string>submit</string>
</list> </list>
</value> </value>
</item> </item>
<item>
<key> <string>right</string> </key>
<value>
<list/>
</value>
</item>
</dictionary> </dictionary>
</value> </value>
</item> </item>
......
...@@ -3,19 +3,16 @@ ...@@ -3,19 +3,16 @@
<record id="1" aka="AAAAAAAAAAE="> <record id="1" aka="AAAAAAAAAAE=">
<pickle> <pickle>
<tuple> <tuple>
<tuple> <global name="ProxyField" module="Products.ERP5Form.ProxyField"/>
<string>Products.ERP5Form.InputButtonField</string> <tuple/>
<string>InputButtonField</string>
</tuple>
<none/>
</tuple> </tuple>
</pickle> </pickle>
<pickle> <pickle>
<dictionary> <dictionary>
<item> <item>
<key> <string>_owner</string> </key> <key> <string>delegated_list</string> </key>
<value> <value>
<none/> <list/>
</value> </value>
</item> </item>
<item> <item>
...@@ -25,7 +22,12 @@ ...@@ -25,7 +22,12 @@
<item> <item>
<key> <string>message_values</string> </key> <key> <string>message_values</string> </key>
<value> <value>
<dictionary/> <dictionary>
<item>
<key> <string>external_validator_failed</string> </key>
<value> <string>The input failed the external validator.</string> </value>
</item>
</dictionary>
</value> </value>
</item> </item>
<item> <item>
...@@ -33,43 +35,15 @@ ...@@ -33,43 +35,15 @@
<value> <value>
<dictionary> <dictionary>
<item> <item>
<key> <string>alternate_name</string> </key> <key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>css_class</string> </key>
<value> <string></string> </value> <value> <string></string> </value>
</item> </item>
<item> <item>
<key> <string>default</string> </key> <key> <string>form_id</string> </key>
<value> <string></string> </value> <value> <string></string> </value>
</item> </item>
<item> <item>
<key> <string>description</string> </key> <key> <string>target</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>extra</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>hidden</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value> <value> <string></string> </value>
</item> </item>
</dictionary> </dictionary>
...@@ -80,43 +54,15 @@ ...@@ -80,43 +54,15 @@
<value> <value>
<dictionary> <dictionary>
<item> <item>
<key> <string>alternate_name</string> </key> <key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>css_class</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>default</string> </key>
<value> <string></string> </value> <value> <string></string> </value>
</item> </item>
<item> <item>
<key> <string>description</string> </key> <key> <string>form_id</string> </key>
<value> <string></string> </value> <value> <string></string> </value>
</item> </item>
<item> <item>
<key> <string>editable</string> </key> <key> <string>target</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>extra</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>hidden</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value> <value> <string></string> </value>
</item> </item>
</dictionary> </dictionary>
...@@ -127,44 +73,16 @@ ...@@ -127,44 +73,16 @@
<value> <value>
<dictionary> <dictionary>
<item> <item>
<key> <string>alternate_name</string> </key> <key> <string>field_id</string> </key>
<value> <string></string> </value> <value> <string>submit</string> </value>
</item>
<item>
<key> <string>css_class</string> </key>
<value> <string>hiddenLabel</string> </value>
</item>
<item>
<key> <string>default</string> </key>
<value> <string>Create</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>extra</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>hidden</string> </key>
<value> <int>0</int> </value>
</item> </item>
<item> <item>
<key> <string>name</string> </key> <key> <string>form_id</string> </key>
<value> <string>WebSite_createWebSiteAccount:action</string> </value> <value> <string>WebSite_viewRegistrationFieldLibrary</string> </value>
</item> </item>
<item> <item>
<key> <string>title</string> </key> <key> <string>target</string> </key>
<value> <string>Submit</string> </value> <value> <string>Click to edit the target</string> </value>
</item> </item>
</dictionary> </dictionary>
</value> </value>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<global name="ERP5Form" module="Products.ERP5Form.Form"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<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/>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_objects</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>_owner</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>action</string> </key>
<value> <string>WebSite_createPersonAccount</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>encoding</string> </key>
<value> <string>UTF-8</string> </value>
</item>
<item>
<key> <string>enctype</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>group_list</string> </key>
<value>
<list>
<string>left</string>
<string>right</string>
<string>center</string>
<string>bottom</string>
</list>
</value>
</item>
<item>
<key> <string>groups</string> </key>
<value>
<dictionary>
<item>
<key> <string>bottom</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>center</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>left</string> </key>
<value>
<list>
<string>your_first_name</string>
<string>your_last_name</string>
<string>your_default_email_text</string>
<string>your_default_telephone_text</string>
<string>your_default_fax_text</string>
<string>your_default_address_street_address</string>
<string>your_default_address_city</string>
<string>your_default_address_zip_code</string>
<string>your_default_address_region</string>
<string>your_reference</string>
<string>your_password</string>
<string>your_password_confirm</string>
<string>submit</string>
</list>
</value>
</item>
<item>
<key> <string>right</string> </key>
<value>
<list/>
</value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>WebSite_viewRegistrationFieldLibrary</string> </value>
</item>
<item>
<key> <string>method</string> </key>
<value> <string>POST</string> </value>
</item>
<item>
<key> <string>name</string> </key>
<value> <string>WebSite_createWebSiteAccountForm</string> </value>
</item>
<item>
<key> <string>pt</string> </key>
<value> <string>form_view_editable</string> </value>
</item>
<item>
<key> <string>row_length</string> </key>
<value> <int>4</int> </value>
</item>
<item>
<key> <string>stored_encoding</string> </key>
<value> <string>UTF-8</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Registration Field Library</string> </value>
</item>
<item>
<key> <string>unicode_mode</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>update_action</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<global name="InputButtonField" module="Products.ERP5Form.InputButtonField"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>submit</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
<value>
<dictionary/>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>alternate_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>css_class</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>default</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>extra</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>hidden</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>alternate_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>css_class</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>default</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>extra</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>hidden</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>alternate_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>css_class</string> </key>
<value> <string>hiddenLabel</string> </value>
</item>
<item>
<key> <string>default</string> </key>
<value> <string>Register New User</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>extra</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>hidden</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>name</string> </key>
<value> <string>WebSite_createWebSiteAccount:action</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Register</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
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