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

Also report invalid IDs in category spread sheet import

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@24911 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent ebe023da
...@@ -90,6 +90,13 @@ def default_invalid_spreadsheet_error_handler(error_message):\n ...@@ -90,6 +90,13 @@ def default_invalid_spreadsheet_error_handler(error_message):\n
if invalid_spreadsheet_error_handler is None:\n if invalid_spreadsheet_error_handler is None:\n
invalid_spreadsheet_error_handler = default_invalid_spreadsheet_error_handler\n invalid_spreadsheet_error_handler = default_invalid_spreadsheet_error_handler\n
\n \n
try:\n
property_id_list = context.portal_classes.getPropertySheetPropertyIdList()\n
except AttributeError:\n
# Class tool is too old\n
property_id_list = []\n
\n
\n
def getIDFromString(string=None):\n def getIDFromString(string=None):\n
"""\n """\n
This function transform a string to a safe and beautiful ID.\n This function transform a string to a safe and beautiful ID.\n
...@@ -122,6 +129,12 @@ def getIDFromString(string=None):\n ...@@ -122,6 +129,12 @@ def getIDFromString(string=None):\n
clean_id = clean_id[1:]\n clean_id = clean_id[1:]\n
while len(clean_id) > 0 and not clean_id[-1].isalnum():\n while len(clean_id) > 0 and not clean_id[-1].isalnum():\n
clean_id = clean_id[:-1]\n clean_id = clean_id[:-1]\n
\n
if clean_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=clean_id)))\n
\n
return clean_id\n return clean_id\n
\n \n
# if the file is not an open office format, try to convert it using oood\n # if the file is not an open office format, try to convert it using oood\n
...@@ -331,13 +344,15 @@ return categories_spreadsheet_mapping\n ...@@ -331,13 +344,15 @@ return categories_spreadsheet_mapping\n
<string>categories_spreadsheet_mapping</string> <string>categories_spreadsheet_mapping</string>
<string>default_invalid_spreadsheet_error_handler</string> <string>default_invalid_spreadsheet_error_handler</string>
<string>None</string> <string>None</string>
<string>_getattr_</string>
<string>context</string>
<string>property_id_list</string>
<string>AttributeError</string>
<string>getIDFromString</string> <string>getIDFromString</string>
<string>content_type</string> <string>content_type</string>
<string>hasattr</string> <string>hasattr</string>
<string>_getattr_</string>
<string>Products.ERP5Type.Document</string> <string>Products.ERP5Type.Document</string>
<string>newTempOOoDocument</string> <string>newTempOOoDocument</string>
<string>context</string>
<string>tmp_ooo</string> <string>tmp_ooo</string>
<string>_getiter_</string> <string>_getiter_</string>
<string>ignored</string> <string>ignored</string>
......
...@@ -99,6 +99,7 @@ filename = getattr(import_file, \'filename\', \'?\')\n ...@@ -99,6 +99,7 @@ filename = getattr(import_file, \'filename\', \'?\')\n
def invalid_category_spreadsheet_handler(message):\n def invalid_category_spreadsheet_handler(message):\n
# action taken when an invalid spreadsheet is provided.\n # action taken when an invalid spreadsheet is provided.\n
# we *raise* a Redirect, because we don\'t want the transaction to succeed\n # we *raise* a Redirect, because we don\'t want the transaction to succeed\n
# note, we could make a dialog parameter to allow import invalid spreadsheet:\n
raise \'Redirect\', \'%s/view?portal_status_message=%s\' % (\n raise \'Redirect\', \'%s/view?portal_status_message=%s\' % (\n
context.portal_categories.absolute_url(),\n context.portal_categories.absolute_url(),\n
message)\n message)\n
......
1043 1044
\ 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