Commit 2bd5e31f authored by Vincent Pelletier's avatar Vincent Pelletier

ERP5Catalog.CatalogTool: Support all catalog columns in auto-generated related keys.

parent 4711e761
...@@ -893,6 +893,7 @@ class CatalogTool (UniqueObject, ZCatalog, CMFCoreCatalogTool, ActiveObject): ...@@ -893,6 +893,7 @@ class CatalogTool (UniqueObject, ZCatalog, CMFCoreCatalogTool, ActiveObject):
default_string = 'default_' default_string = 'default_'
strict_string = 'strict_' strict_string = 'strict_'
related_string = 'related_' related_string = 'related_'
column_map = self.getSQLCatalog(sql_catalog_id).getColumnMap()
for key in key_list: for key in key_list:
prefix = '' prefix = ''
strict = 0 strict = 0
...@@ -915,10 +916,10 @@ class CatalogTool (UniqueObject, ZCatalog, CMFCoreCatalogTool, ActiveObject): ...@@ -915,10 +916,10 @@ class CatalogTool (UniqueObject, ZCatalog, CMFCoreCatalogTool, ActiveObject):
related = end_key.startswith(related_string) related = end_key.startswith(related_string)
if related: if related:
end_key = end_key[len(related_string):] end_key = end_key[len(related_string):]
# accept only some catalog columns # XXX: joining with non-catalog tables is not trivial and requires
if end_key in ('title', 'uid', 'description', 'reference', # ZSQLCatalog's ColumnMapper cooperation, so only allow catalog
'relative_url', 'id', 'portal_type', # columns.
'simulation_state'): if 'catalog' in column_map.get(end_key, ()):
is_uid = end_key == 'uid' is_uid = end_key == 'uid'
if is_uid: if is_uid:
end_key = 'uid' if related else 'category_uid' end_key = 'uid' if related else 'category_uid'
......
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