Commit e2b6ba71 authored by Jérome Perrin's avatar Jérome Perrin

detect duplicates IDs when importing categories

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@24906 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 7f5f53e6
...@@ -247,6 +247,14 @@ for table_name in spreadsheets.keys():\n ...@@ -247,6 +247,14 @@ for table_name in spreadsheets.keys():\n
# (i.e. its tranformation to ID is not the same as the original value)\n # (i.e. its tranformation to ID is not the same as the original value)\n
if clean_title != cell_id:\n if clean_title != cell_id:\n
category_properties[\'title\'] = clean_title\n category_properties[\'title\'] = clean_title\n
\n
# Detect duplicate IDs\n
#if path_elements and path_elements[-1][\'depth\'] == element_depth:\n
for element in path_elements[::-1]:\n
if element[\'depth\'] != element_depth:\n
break\n
if element[\'value\'] == path_element_id:\n
raise ValueError("Duplicate id %s" % element[\'value\'])\n
\n \n
# Save the path element\n # Save the path element\n
path_elements.append({ \'depth\': element_depth\n path_elements.append({ \'depth\': element_depth\n
...@@ -355,6 +363,7 @@ return categories_spreadsheet_mapping\n ...@@ -355,6 +363,7 @@ return categories_spreadsheet_mapping\n
<string>element</string> <string>element</string>
<string>path</string> <string>path</string>
<string>clean_title</string> <string>clean_title</string>
<string>ValueError</string>
</tuple> </tuple>
</value> </value>
</item> </item>
......
1040 1042
\ 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