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

- also support the category relative URL for categories columns

- lots of cleanups

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@30927 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 6916bd18
...@@ -59,9 +59,6 @@ forbidden_property = [\'uid\', \'id\', \'portal_type\']\n ...@@ -59,9 +59,6 @@ forbidden_property = [\'uid\', \'id\', \'portal_type\']\n
property_list = []\n property_list = []\n
\n \n
for portal_type in module.allowedContentTypes():\n for portal_type in module.allowedContentTypes():\n
#for property in portal_type.getInstancePropertyMap():\n
#property_string = "%s.%s" % (portal_type.id, property[\'id\'])\n
#property_list.append(property_string)\n
for property in portal_type.getInstancePropertyAndBaseCategoryList():\n for property in portal_type.getInstancePropertyAndBaseCategoryList():\n
if property not in forbidden_property:\n if property not in forbidden_property:\n
property_list.append((portal_type.id, property))\n property_list.append((portal_type.id, property))\n
......
...@@ -222,7 +222,7 @@ else:\n ...@@ -222,7 +222,7 @@ else:\n
if imported_line_property_dict not in [{}, None]:\n if imported_line_property_dict not in [{}, None]:\n
tag = "OOo_import_%s" % active_process_value.getId()\n tag = "OOo_import_%s" % active_process_value.getId()\n
portal_type = mapping[spreadsheet_name][0]\n portal_type = mapping[spreadsheet_name][0]\n
active_process = context.activate(tag=tag,\n active_object = context.activate(tag=tag,\n
priority=1,\n priority=1,\n
activity="SQLQueue",\n activity="SQLQueue",\n
active_process=active_process_path)\n active_process=active_process_path)\n
...@@ -230,7 +230,7 @@ else:\n ...@@ -230,7 +230,7 @@ else:\n
if getattr(context, import_file_line_script, None) is None:\n if getattr(context, import_file_line_script, None) is None:\n
raise AttributeError, \'specified script "%s" does not exists\' % import_file_line_script\n raise AttributeError, \'specified script "%s" does not exists\' % import_file_line_script\n
\n \n
getattr(active_process, import_file_line_script)(context.getRelativeUrl(),\n getattr(active_object, import_file_line_script)(context.getRelativeUrl(),\n
portal_type,\n portal_type,\n
imported_line_property_dict,\n imported_line_property_dict,\n
active_process=active_process_path)\n active_process=active_process_path)\n
...@@ -349,7 +349,7 @@ raise NotImplementedError\n ...@@ -349,7 +349,7 @@ raise NotImplementedError\n
<string>property_value</string> <string>property_value</string>
<string>property_id</string> <string>property_id</string>
<string>tag</string> <string>tag</string>
<string>active_process</string> <string>active_object</string>
<string>NotImplementedError</string> <string>NotImplementedError</string>
</tuple> </tuple>
</value> </value>
......
...@@ -161,7 +161,9 @@ else:\n ...@@ -161,7 +161,9 @@ else:\n
\n \n
if not success:\n if not success:\n
# Delete the object if error occurs\n # Delete the object if error occurs\n
# FIXME: maybe this should be an option ?\n
container.manage_delObjects([new_object.getId()])\n container.manage_delObjects([new_object.getId()])\n
\n
return {\n return {\n
\'message\': translated_msg,\n \'message\': translated_msg,\n
\'object_url\': new_object.getRelativeUrl(),\n \'object_url\': new_object.getRelativeUrl(),\n
......
...@@ -442,13 +442,17 @@ ...@@ -442,13 +442,17 @@
<key> <string>hidden</string> </key> <key> <string>hidden</string> </key>
<value> <int>0</int> </value> <value> <int>0</int> </value>
</item> </item>
<item>
<key> <string>hide_rows_on_no_search_criterion</string> </key>
<value> <int>0</int> </value>
</item>
<item> <item>
<key> <string>lines</string> </key> <key> <string>lines</string> </key>
<value> <int>200</int> </value> <value> <int>200</int> </value>
</item> </item>
<item> <item>
<key> <string>list_action</string> </key> <key> <string>list_action</string> </key>
<value> <string>Folder_viewContentList</string> </value> <value> <string></string> </value>
</item> </item>
<item> <item>
<key> <string>list_method</string> </key> <key> <string>list_method</string> </key>
...@@ -490,6 +494,10 @@ ...@@ -490,6 +494,10 @@
<key> <string>report_tree</string> </key> <key> <string>report_tree</string> </key>
<value> <int>0</int> </value> <value> <int>0</int> </value>
</item> </item>
<item>
<key> <string>row_css_method</string> </key>
<value> <string></string> </value>
</item>
<item> <item>
<key> <string>search</string> </key> <key> <string>search</string> </key>
<value> <int>0</int> </value> <value> <int>0</int> </value>
...@@ -543,7 +551,16 @@ ...@@ -543,7 +551,16 @@
<item> <item>
<key> <string>url_columns</string> </key> <key> <string>url_columns</string> </key>
<value> <value>
<list/> <list>
<tuple>
<string>spreadsheet_name</string>
<string></string>
</tuple>
<tuple>
<string>spreadsheet_column</string>
<string></string>
</tuple>
</list>
</value> </value>
</item> </item>
<item> <item>
......
...@@ -194,7 +194,7 @@ ...@@ -194,7 +194,7 @@
</item> </item>
<item> <item>
<key> <string>css_class</string> </key> <key> <string>css_class</string> </key>
<value> <string></string> </value> <value> <string>invisible</string> </value>
</item> </item>
<item> <item>
<key> <string>default</string> </key> <key> <string>default</string> </key>
......
...@@ -53,44 +53,37 @@ ...@@ -53,44 +53,37 @@
</item> </item>
<item> <item>
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string encoding="cdata"><![CDATA[ <value> <string>"""Guess the path of categories, taking as input a mapping {base_category:\n
category}, where category can be the relative_url, the title or the reference\n
# get a dict like {\'religion\': \'MRD\', \'gender\': \'M\'} and returns {\'religion\': \'MSM/MRD\', gender: \'male\'} so that \n of the category\n
# we can call an edit(category_dict) directly on the object it browse recursively the subcategories of the \n """\n
# category (key in the dict) and find a matching reference or title.\n
# Christophe Dumez <christophe@nexedi.com>\n
\n
#def getMatchingCategoryUsingCodification(root_category, codification):\n
# sub_cat_list = root_category.objectValues()\n
# for sub_cat in sub_cat_list:\n
# if sub_cat.getCodification() == codification:\n
# return sub_cat\n
# matching_cat = getMatchingCategoryUsingCodification(sub_cat, codification)\n
# if matching_cat is not None:\n
# return matching_cat\n
\n \n
from Products.ZSQLCatalog.SQLCatalog import Query, ComplexQuery\n
portal = context.getPortalObject()\n
result_dict = {}\n result_dict = {}\n
for category_name in category_dict.keys():\n \n
subcat_code = category_dict[category_name]\n for base_category_name, category in category_dict.items():\n
category_object = context.getPortalObject().portal_categories[category_name]\n category_object = \\\n
result_list = context.portal_catalog(portal_type=\'Category\', reference=\'=\'+str(subcat_code), relative_url=category_name+\'%\')\n context.getPortalObject().portal_categories[base_category_name]\n
if len(result_list) != 0:\n \n
result_cat_fullpath = \'/\'.join(result_list[0].getRelativeUrl().split(\'/\')[1:])\n category_value = category_object.restrictedTraverse(category, None)\n
result_dict[category_name]=result_cat_fullpath\n if category_value is None:\n
else:\n query = ComplexQuery(\n
result_list = context.portal_catalog(portal_type=\'Category\', title=\'=\'+str(subcat_code), relative_url=category_name+\'%\')\n ComplexQuery(Query(title=category,\n
if len(result_list) != 0:\n key=\'ExactMatch\'),\n
result_cat_fullpath = \'/\'.join(result_list[0].getRelativeUrl().split(\'/\')[1:])\n Query(reference=category,\n
result_dict[category_name]=result_cat_fullpath\n key=\'ExactMatch\'),\n
#result_cat = getMatchingCategoryUsingCodification(root_category=category_object, codification=subcat_code)\n operator=\'OR\'),\n
#if result_cat is not None:\n ComplexQuery(Query(relative_url=\'%s/%%\' % base_category_name)))\n
# result_cat_fullpath = \'/\'.join(result_cat.getPath().split(\'/\')[4:])\n category_value = portal.portal_catalog.getResultValue(query=query)\n
# result_dict[category_name]=result_cat_fullpath\n \n
if category_value is not None:\n
# remove base category from relative_url\n
result_dict[base_category_name] = \\\n
category_value.getRelativeUrl().split(\'/\', 1)[1]\n
\n \n
return result_dict\n return result_dict\n
</string> </value>
]]></string> </value>
</item> </item>
<item> <item>
<key> <string>_code</string> </key> <key> <string>_code</string> </key>
...@@ -127,18 +120,21 @@ return result_dict\n ...@@ -127,18 +120,21 @@ return result_dict\n
<value> <value>
<tuple> <tuple>
<string>category_dict</string> <string>category_dict</string>
<string>Products.ZSQLCatalog.SQLCatalog</string>
<string>Query</string>
<string>ComplexQuery</string>
<string>_getattr_</string>
<string>context</string>
<string>portal</string>
<string>result_dict</string> <string>result_dict</string>
<string>_getiter_</string> <string>_getiter_</string>
<string>_getattr_</string> <string>base_category_name</string>
<string>category_name</string> <string>category</string>
<string>_getitem_</string> <string>_getitem_</string>
<string>subcat_code</string>
<string>context</string>
<string>category_object</string> <string>category_object</string>
<string>str</string> <string>None</string>
<string>result_list</string> <string>category_value</string>
<string>len</string> <string>query</string>
<string>result_cat_fullpath</string>
<string>_write_</string> <string>_write_</string>
</tuple> </tuple>
</value> </value>
......
394 398
\ 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