Commit b98afcd4 authored by Mame Coumba Sall's avatar Mame Coumba Sall

Modify to take into account proxification of all forms

parent b344ea17
...@@ -75,35 +75,52 @@ LOWERCASE_WORD_DICT = dict([(word, 1) for word in LOWERCASE_WORD_LIST])\n ...@@ -75,35 +75,52 @@ LOWERCASE_WORD_DICT = dict([(word, 1) for word in LOWERCASE_WORD_LIST])\n
# List of allowed characters, usefull to detect non-english strings\n # List of allowed characters, usefull to detect non-english strings\n
ALLOWED_CHARS = \'abcdefghijklmnopqrstuvwxyz0123456789%/. ()-_?&\'\n ALLOWED_CHARS = \'abcdefghijklmnopqrstuvwxyz0123456789%/. ()-_?&\'\n
\n \n
\n
\n
def checkField(folder, form, field):\n def checkField(folder, form, field):\n
"""\n """\n
Generic function that test the validity of ERP5Form fields.\n Generic function that test the validity of ERP5Form fields.\n
"""\n """\n
path = \'/\'.join([folder.id, form.id])\n path = \'/\'.join([folder.id, form.id])\n
error_message = checkTitle(path, field.id, field.title())\n error_message = checkTitle(path, field.id, field.title(), field)\n
if field.id == \'listbox\':\n template_field = getFieldFromProxyField(field)\n
if template_field is None:\n
error_message = "Could not get a field from a proxy field %s" % field.id\n
return error_message\n
elif template_field.meta_type == \'ListBox\':\n
a = template_field.getListMethodName() \n
if isListBox(field):\n
path = \'/\'.join([path, \'listbox\'])\n path = \'/\'.join([path, \'listbox\'])\n
for id, title in field.get_value(\'columns\'):\n for id, title in field.get_value(\'columns\'):\n
error_message += checkTitle(path, \'columns\', title)\n error_message += checkTitle(path, \'columns\', title, field)\n
for id, title in field.get_value(\'all_columns\'):\n for id, title in field.get_value(\'all_columns\'):\n
error_message += checkTitle(path, \'all_columns\', title)\n error_message += checkTitle(path, \'all_columns\', title, field)\n
\n \n
a = field.getListMethodName()\n
if (a!= None and not a.endswith(\'List\')):\n if (a!= None and not a.endswith(\'List\')):\n
if a not in [\'portal_catalog\', \'searchFolder\', \'objectValues\']:\n if a not in [\'portal_catalog\', \'searchFolder\', \'objectValues\']:\n
error_message = "%s : %s : %r Bad Naming Convention\\n" % (path, id, a)\n error_message = "%s : %s : %r Bad Naming Convention\\n" % (path, id, a)\n
return error_message\n return error_message\n
\n \n
\n def isListBox(field):\n
def checkTitle(path, id, title):\n template_field = getFieldFromProxyField(field)\n
if template_field is None:\n
return False\n
elif template_field.meta_type == \'ListBox\':\n
return True\n
return False\n
\n
def getFieldFromProxyField(field):\n
if field.meta_type == \'ProxyField\':\n
template_field = field.getRecursiveTemplateField()\n
return template_field\n
return field \n
\n
def checkTitle(path, id, title, field=None):\n
"""\n """\n
Generic function that test the validity of a title.\n Generic function that test the validity of a title.\n
"""\n """\n
error_message = \'\'\n error_message = \'\'\n
\n \n
if len(title.strip()) == 0:\n if (field is not None and not field.get_value(\'hidden\') and \\\n
(title is None or len(title.strip()) == 0)) or (field is None and (title is None or len(title.strip()) == 0)):\n
return "%s : %s : can\'t be empty\\n" % (path, id)\n return "%s : %s : can\'t be empty\\n" % (path, id)\n
\n \n
for c in title:\n for c in title:\n
......
41046 41047
\ 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