Commit 2c0af056 authored by Tomáš Peterka's avatar Tomáš Peterka

[json_style] Support custom selection names for stat scripts

parent 1cfa75e1
...@@ -1682,11 +1682,12 @@ def calculateHateoas(is_portal=None, is_site_root=None, traversed_document=None, ...@@ -1682,11 +1682,12 @@ def calculateHateoas(is_portal=None, is_site_root=None, traversed_document=None,
stat_method = source_field.get_value('stat_method') stat_method = source_field.get_value('stat_method')
stat_columns = source_field.get_value('stat_columns') stat_columns = source_field.get_value('stat_columns')
# support only selection_name for stat methods because any `selection` is deprecated # support only selection_name for stat methods because any `selection` is deprecated
# and should be removed # and should be removed. Selection_name can be passed in catalog_kw by e.g. reports so it has precedence.
# Romain wants full backward compatibility so putting `selection` back in parameters # Romain wants full backward compatibility so putting `selection` back in parameters
selection_name = source_field.get_value('selection_name') selection_name = catalog_kw.get('selection_name', source_field.get_value('selection_name'))
if selection_name and 'selection_name' not in catalog_kw: if selection_name and 'selection_name' not in catalog_kw:
catalog_kw['selection_name'] = selection_name catalog_kw['selection_name'] = selection_name
if 'selection' not in catalog_kw:
catalog_kw['selection'] = context.getPortalObject().portal_selections.getSelectionFor(selection_name, REQUEST) catalog_kw['selection'] = context.getPortalObject().portal_selections.getSelectionFor(selection_name, REQUEST)
contents_stat = {} contents_stat = {}
......
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