Commit 24e66495 authored by Rafael Monnerat's avatar Rafael Monnerat

Improve and fix validation script.

It was broken in a previous modification.
parent ad5722a1
......@@ -50,9 +50,7 @@
</item>
<item>
<key> <string>_body</string> </key>
<value> <string encoding="cdata"><![CDATA[
# check that customer did not enter in form repeating user names\n
<value> <string># check that customer did not enter in form repeating user names\n
reference_list = REQUEST.get(\'_original_field_your_reference\', [])\n
for reference in reference_list:\n
if reference_list.count(reference) != 1:\n
......@@ -60,47 +58,28 @@ for reference in reference_list:\n
return 0\n
\n
portal = context.getPortalObject()\n
reference = kw.get(\'reference\', None)\n
\n
if editor is not None:\n
# script is used as a form field\'s validator\n
reference = editor\n
\n
# get Business Configuration\n
business_configuration = context.restrictedTraverse(REQUEST.get(\'business_configuration_key\'))\n
reference = editor\n
\n
# ... then check already created accounts\n
if portal.portal_catalog.getResultValue(\n
reference=reference, \n
portal_type="Person") is not None:\n
reference = reference, \n
portal_type = "Person") is not None:\n
return 0\n
\n
\n
# first check if a Business Configuration has not already "reserved" it\n
# through a Person Configuration Item which when build will create a real\n
# Nexedi ERP5 account.\n
person_configurator_item_list = [portal.portal_catalog.getResultValue(\n
reference=reference,\n
portal_type=\'Person Configurator Item\')]\n
\n
if business_configuration is not None:\n
# when in Configuratorm mode we the user may have created already Person Configurator Item\n
# in this business configuration. Make sure that going to Previous page will not stop\n
# validation of username uniqueness \n
# XXX: this should be done using a ZSQL Query rather than getting object\n
# there should not be a speed penalty of loading objects in RAM as in most cases\n
# it\'s either 0 (i.e. not used) or 1 (used)\n
person_configurator_item_list = filter(lambda x: x.getObject().getParentValue().getParentValue() == \n
business_configuration, \\\n
person_configurator_item_list)\n
bc_path = " NOT %%/%s/%%" % REQUEST.get(\'business_configuration_key\')\n
\n
if len(person_configurator_item_list) > 0:\n
if portal.portal_catalog.getResultValue(\n
reference = reference,\n
portal_type=\'Person Configurator Item\',\n
path = bc_path) is not None:\n
return 0\n
\n
return 1\n
]]></string> </value>
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
......
523
\ No newline at end of file
524
\ 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