Commit ea0d8dd4 authored by Ivan Tyagov's avatar Ivan Tyagov

Added simple registration form and user creation script.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@14866 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent aa4c3584
<?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
This script is a sample script sceleton (part of erp5_web)\n
which can be used to create user (Person object) \n
\n
Notes:\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 decide if assignment should be opened automatically or \n
verified and opened by administrator first\n
- you need to adjust group, function and site to your needs\n
"""\n
from Products.Formulator.Errors import ValidationError, FormValidationError\n
\n
# validate form manually\n
form = context.WebSite_createWebSiteAccountForm\n
try:\n
form.validate_all_to_request(context.REQUEST)\n
except (FormValidationError, ValidationError,), validation_errors:\n
context.REQUEST.set(\'field_errors\', form.ErrorFields(validation_errors)) \n
return form()\n
\n
# extract only user details\n
kw = context.REQUEST.form\n
filtered_kw = {}\n
prefix = \'field_your_\'\n
for key in kw.keys():\n
if key.startswith(prefix):\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
# create Person account\n
person_module = context.getPortalObject().person_module\n
person = person_module.newContent(portal_type = \'Person\', \n
**filtered_kw)\n
\n
# create default career\n
career = person.newContent(portal_type = \'Career\', \n
id = \'default_career\', \n
group = person_group, \n
function = person_function,\n
role = person_role)\n
# create assignment\n
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
\n
translateString = context.Base_translateString\n
msg = translateString("Your account was successfully created.")\n
website = context.getWebSiteValue()\n
return website.Base_redirect(\'view\', \n
keep_items = dict(portal_status_message = msg,\n
editable_mode = 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></string> </value>
</item>
<item>
<key> <string>_proxy_roles</string> </key>
<value>
<tuple/>
</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>0</int> </value>
</item>
<item>
<key> <string>co_varnames</string> </key>
<value>
<tuple>
<string>Products.Formulator.Errors</string>
<string>ValidationError</string>
<string>FormValidationError</string>
<string>_getattr_</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>key</string>
<string>_getitem_</string>
<string>_write_</string>
<string>person_group</string>
<string>person_function</string>
<string>person_site</string>
<string>person_role</string>
<string>person_module</string>
<string>_apply_</string>
<string>person</string>
<string>career</string>
<string>assignment</string>
<string>translateString</string>
<string>msg</string>
<string>website</string>
<string>dict</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_createWebSiteAccount</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Create Web Site User Account</string> </value>
</item>
<item>
<key> <string>warnings</string> </key>
<value>
<tuple/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<tuple>
<string>Products.ERP5Form.Form</string>
<string>ERP5Form</string>
</tuple>
<none/>
</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>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>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_createWebSiteAccountForm</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</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>Create Your New Account</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>
<tuple>
<string>Products.ERP5Form.InputButtonField</string>
<string>InputButtonField</string>
</tuple>
<none/>
</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>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>
<key> <string>name</string> </key>
<value> <string>WebSite_createWebSiteAccount:action</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Submit</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -69,37 +69,10 @@ ...@@ -69,37 +69,10 @@
<item> <item>
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string>"""\n <value> <string>"""\n
This script is part of erp5_web.\n Check if provided user reference is not already used in the system.\n
It\'s a sample script sceleton which can be used to create user (Person object) \n
for web interface and sets Person\'s details (address, email, assignment and career). \n
\n
Notes:\n
- This 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
- this script should be called from respective form which will handle all validation\n
- you have to decide if assignment should be opened automatically or \n
verified and opened by administrator first\n
"""\n """\n
\n user_list = context.acl_users.searchUsers(id=editor, exact_match=True)\n
person_module = context.getPortalObject().person_module\n return len(user_list)==0\n
person = person_module.newContent(portal_type = \'Person\', \n
reference = kw[\'email\'],\n
default_email_text = kw[\'email\'],\n
first_name = kw[\'first_name\'], \n
last_name = kw[\'last_name\'])\n
# create default career\n
career = person.newContent(portal_type=\'Career\', \n
id=\'default_career\', \n
group=kw[\'group\'], \n
function=kw[\'function\'], \n
role=\'internal\')\n
# create assignment\n
assignment = person.newContent(portal_type=\'Assignment\', \n
group=kw[\'group\'], \n
function=kw[\'function\'], \n
site=kw[\'site\'])\n
person.submit()\n
return person\n
</string> </value> </string> </value>
</item> </item>
<item> <item>
...@@ -122,14 +95,14 @@ return person\n ...@@ -122,14 +95,14 @@ return person\n
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string>**kw</string> </value> <value> <string>editor, request</string> </value>
</item> </item>
<item> <item>
<key> <string>_proxy_roles</string> </key> <key> <string>_proxy_roles</string> </key>
<value> <value>
<tuple> <tuple>
<string>Assignor</string> <string>Assignor</string>
<string>Author</string> <string>Manager</string>
</tuple> </tuple>
</value> </value>
</item> </item>
...@@ -151,20 +124,19 @@ return person\n ...@@ -151,20 +124,19 @@ return person\n
<dictionary> <dictionary>
<item> <item>
<key> <string>co_argcount</string> </key> <key> <string>co_argcount</string> </key>
<value> <int>0</int> </value> <value> <int>2</int> </value>
</item> </item>
<item> <item>
<key> <string>co_varnames</string> </key> <key> <string>co_varnames</string> </key>
<value> <value>
<tuple> <tuple>
<string>kw</string> <string>editor</string>
<string>request</string>
<string>_getattr_</string> <string>_getattr_</string>
<string>context</string> <string>context</string>
<string>person_module</string> <string>True</string>
<string>_getitem_</string> <string>user_list</string>
<string>person</string> <string>len</string>
<string>career</string>
<string>assignment</string>
</tuple> </tuple>
</value> </value>
</item> </item>
...@@ -181,11 +153,11 @@ return person\n ...@@ -181,11 +153,11 @@ return person\n
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>WebSite_createUser</string> </value> <value> <string>WebSite_isValidUserReference</string> </value>
</item> </item>
<item> <item>
<key> <string>title</string> </key> <key> <string>title</string> </key>
<value> <string>Create web site user</string> </value> <value> <string>Is Valid User Reference Provided?</string> </value>
</item> </item>
<item> <item>
<key> <string>warnings</string> </key> <key> <string>warnings</string> </key>
......
552 559
\ 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