From 26fd2f9dd7142d42043f91f8715a4c130ac419e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9rome=20Perrin?= <jerome@nexedi.com> Date: Wed, 17 Dec 2008 12:08:48 +0000 Subject: [PATCH] Detect and report wrong hierarchy in category spreadsheet git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@24922 20353a03-c40f-0410-a6d1-a30d3c3de9de --- .../Base_getCategoriesSpreadSheetMapping.xml | 19 +++++++++++++++++++ product/ERP5/bootstrap/erp5_core/bt/revision | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) 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 73524f016d..7aa576b547 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 @@ -283,6 +283,24 @@ for table_name in spreadsheets.keys():\n translateString("Duplicate id found: ${id}",\n mapping=dict(id=element[\'value\'])))\n \n + # Detect wrong hierarchy\n + if path_elements:\n + current_depth = element_depth\n + for element in path_elements[::-1]:\n + if element[\'depth\'] > current_depth:\n + break # we are now on another branch\n + if element[\'depth\'] == current_depth:\n + continue # we are on the same level\n + elif element[\'depth\'] == (current_depth - 1):\n + current_depth = element[\'depth\']\n + continue # we are on the direct parent (current level - 1)\n + else:\n + invalid_spreadsheet_error_handler(\n + translateString(\n + "Wrong hierarchy found for ID ${id} and depth ${depth}",\n + mapping=dict(id=path_element_id,\n + depth=element_depth)))\n + \n # Save the path element\n path_elements.append({ \'depth\': element_depth\n , \'value\': path_element_id\n @@ -396,6 +414,7 @@ return categories_spreadsheet_mapping\n <string>element</string> <string>path</string> <string>clean_title</string> + <string>current_depth</string> </tuple> </value> </item> diff --git a/product/ERP5/bootstrap/erp5_core/bt/revision b/product/ERP5/bootstrap/erp5_core/bt/revision index c16c9d01f8..ffef16936c 100644 --- a/product/ERP5/bootstrap/erp5_core/bt/revision +++ b/product/ERP5/bootstrap/erp5_core/bt/revision @@ -1 +1 @@ -1046 \ No newline at end of file +1047 \ No newline at end of file -- 2.30.9