Commit 5bc569f0 authored by Jean-Paul Smets's avatar Jean-Paul Smets

Made category import less strict (it was too stick because it was checking all...

Made category import less strict (it was too stick because it was checking all values, even those which were not used as IDs)

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@25572 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 5bdf808b
......@@ -97,7 +97,7 @@ except AttributeError:\n
property_id_list = []\n
\n
\n
def getIDFromString(string=None, force=0):\n
def getIDFromString(string=None):\n
"""\n
This function transform a string to a safe and beautiful ID.\n
It is used here to create a safe category ID from a string.\n
......@@ -129,11 +129,6 @@ def getIDFromString(string=None, force=0):\n
clean_id = clean_id[1:]\n
while len(clean_id) > 0 and not clean_id[-1].isalnum():\n
clean_id = clean_id[:-1]\n
\n
if clean_id in property_id_list and not force:\n
invalid_spreadsheet_error_handler(translateString(\n
"The ID ${id} is invalid, it\'s a reserved property name",\n
mapping=dict(id=clean_id)))\n
\n
return clean_id\n
\n
......@@ -167,7 +162,7 @@ for table_name in spreadsheets.keys():\n
column_index = 0\n
path_index = 0\n
for column in columns_header:\n
column_id = getIDFromString(column, force=1)\n
column_id = getIDFromString(column)\n
# This give us the information that the path definition has started\n
path_def_started = \'path_0\' in property_map.values()\n
# The path of the category has started to be expressed\n
......@@ -218,7 +213,7 @@ for table_name in spreadsheets.keys():\n
line_data[property_id] = cell\n
cell_index += 1\n
\n
# Analyse every cells of the line\n
# Analyse every cell of the line\n
category_properties = {}\n
cell_index = 0\n
for (property_id, cell_data) in line_data.items():\n
......@@ -226,7 +221,7 @@ for table_name in spreadsheets.keys():\n
# Try to generate a cell id from cell data\n
cell_id = getIDFromString(cell_data)\n
# Returned cell_id can be None or \'\' (empty string). Both have different meaning:\n
# None : no data was inputed by the user.\n
# None : no data was input by the user.\n
# \'\' : data entered by the user, but no good transformation of the string to a safe ID.\n
\n
# If the cell_id tranformation return an empty string, and if the cell is a path item,\n
......@@ -273,6 +268,12 @@ for table_name in spreadsheets.keys():\n
# (i.e. its tranformation to ID is not the same as the original value)\n
if clean_title != cell_id:\n
category_properties[\'title\'] = clean_title\n
\n
# Detect illegal IDs\n
if path_element_id in property_id_list:\n
invalid_spreadsheet_error_handler(translateString(\n
"The ID ${id} is invalid, it\'s a reserved property name",\n
mapping=dict(id=path_element_id)))\n
\n
# Detect duplicate IDs\n
for element in path_elements[::-1]:\n
......
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