From 5bc569f01a2dbeb92c6be9390f61253a56be532b Mon Sep 17 00:00:00 2001
From: Jean-Paul Smets <jp@nexedi.com>
Date: Sun, 15 Feb 2009 15:06:07 +0000
Subject: [PATCH] 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
---
 .../Base_getCategoriesSpreadSheetMapping.xml  | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_getCategoriesSpreadSheetMapping.xml b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_getCategoriesSpreadSheetMapping.xml
index 7aa576b547..99ff6a0d29 100644
--- a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_getCategoriesSpreadSheetMapping.xml
+++ b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_getCategoriesSpreadSheetMapping.xml
@@ -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
-- 
2.30.9