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
property_list = []\n
\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
if property not in forbidden_property:\n
property_list.append((portal_type.id, property))\n
......
......@@ -222,7 +222,7 @@ else:\n
if imported_line_property_dict not in [{}, None]:\n
tag = "OOo_import_%s" % active_process_value.getId()\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
activity="SQLQueue",\n
active_process=active_process_path)\n
......@@ -230,7 +230,7 @@ else:\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
\n
getattr(active_process, import_file_line_script)(context.getRelativeUrl(),\n
getattr(active_object, import_file_line_script)(context.getRelativeUrl(),\n
portal_type,\n
imported_line_property_dict,\n
active_process=active_process_path)\n
......@@ -349,7 +349,7 @@ raise NotImplementedError\n
<string>property_value</string>
<string>property_id</string>
<string>tag</string>
<string>active_process</string>
<string>active_object</string>
<string>NotImplementedError</string>
</tuple>
</value>
......
......@@ -161,7 +161,9 @@ else:\n
\n
if not success:\n
# Delete the object if error occurs\n
# FIXME: maybe this should be an option ?\n
container.manage_delObjects([new_object.getId()])\n
\n
return {\n
\'message\': translated_msg,\n
\'object_url\': new_object.getRelativeUrl(),\n
......
......@@ -442,13 +442,17 @@
<key> <string>hidden</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>hide_rows_on_no_search_criterion</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>lines</string> </key>
<value> <int>200</int> </value>
</item>
<item>
<key> <string>list_action</string> </key>
<value> <string>Folder_viewContentList</string> </value>
<value> <string></string> </value>
</item>
<item>
<key> <string>list_method</string> </key>
......@@ -490,6 +494,10 @@
<key> <string>report_tree</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>row_css_method</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>search</string> </key>
<value> <int>0</int> </value>
......@@ -543,7 +551,16 @@
<item>
<key> <string>url_columns</string> </key>
<value>
<list/>
<list>
<tuple>
<string>spreadsheet_name</string>
<string></string>
</tuple>
<tuple>
<string>spreadsheet_column</string>
<string></string>
</tuple>
</list>
</value>
</item>
<item>
......
......@@ -194,7 +194,7 @@
</item>
<item>
<key> <string>css_class</string> </key>
<value> <string></string> </value>
<value> <string>invisible</string> </value>
</item>
<item>
<key> <string>default</string> </key>
......
......@@ -53,44 +53,37 @@
</item>
<item>
<key> <string>_body</string> </key>
<value> <string encoding="cdata"><![CDATA[
# get a dict like {\'religion\': \'MRD\', \'gender\': \'M\'} and returns {\'religion\': \'MSM/MRD\', gender: \'male\'} so that \n
# we can call an edit(category_dict) directly on the object it browse recursively the subcategories of the \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
<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
of the category\n
"""\n
\n
from Products.ZSQLCatalog.SQLCatalog import Query, ComplexQuery\n
portal = context.getPortalObject()\n
result_dict = {}\n
for category_name in category_dict.keys():\n
subcat_code = category_dict[category_name]\n
category_object = context.getPortalObject().portal_categories[category_name]\n
result_list = context.portal_catalog(portal_type=\'Category\', reference=\'=\'+str(subcat_code), relative_url=category_name+\'%\')\n
if len(result_list) != 0:\n
result_cat_fullpath = \'/\'.join(result_list[0].getRelativeUrl().split(\'/\')[1:])\n
result_dict[category_name]=result_cat_fullpath\n
else:\n
result_list = context.portal_catalog(portal_type=\'Category\', title=\'=\'+str(subcat_code), relative_url=category_name+\'%\')\n
if len(result_list) != 0:\n
result_cat_fullpath = \'/\'.join(result_list[0].getRelativeUrl().split(\'/\')[1:])\n
result_dict[category_name]=result_cat_fullpath\n
#result_cat = getMatchingCategoryUsingCodification(root_category=category_object, codification=subcat_code)\n
#if result_cat is not None:\n
# result_cat_fullpath = \'/\'.join(result_cat.getPath().split(\'/\')[4:])\n
# result_dict[category_name]=result_cat_fullpath\n
\n
for base_category_name, category in category_dict.items():\n
category_object = \\\n
context.getPortalObject().portal_categories[base_category_name]\n
\n
category_value = category_object.restrictedTraverse(category, None)\n
if category_value is None:\n
query = ComplexQuery(\n
ComplexQuery(Query(title=category,\n
key=\'ExactMatch\'),\n
Query(reference=category,\n
key=\'ExactMatch\'),\n
operator=\'OR\'),\n
ComplexQuery(Query(relative_url=\'%s/%%\' % base_category_name)))\n
category_value = portal.portal_catalog.getResultValue(query=query)\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
return result_dict\n
]]></string> </value>
</string> </value>
</item>
<item>
<key> <string>_code</string> </key>
......@@ -127,18 +120,21 @@ return result_dict\n
<value>
<tuple>
<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>_getiter_</string>
<string>_getattr_</string>
<string>category_name</string>
<string>base_category_name</string>
<string>category</string>
<string>_getitem_</string>
<string>subcat_code</string>
<string>context</string>
<string>category_object</string>
<string>str</string>
<string>result_list</string>
<string>len</string>
<string>result_cat_fullpath</string>
<string>None</string>
<string>category_value</string>
<string>query</string>
<string>_write_</string>
</tuple>
</value>
......
394
\ No newline at end of file
398
\ 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