Commit 8370151d authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

fixup! erp5_core: unify Predicate_edit code into Base_edit.

parent 77037609
......@@ -62,10 +62,7 @@ def editListBox(listbox_field, listbox):
if listbox is None:
return
if context.isPredicate():
predicate_listbox = set(context.getCriterionPropertyList()) == set(listbox.keys())
else:
predicate_listbox = False # extract hidden (global) attributes from request to be used in listbox's update
is_predicate_listbox = set(getattr(context, 'getCriterionPropertyList', lambda: [])()) == set(listbox.keys())
# extract hidden (global) attributes from request to be used in listbox's update
global_attr = {hidden_key: getattr(request, hidden_key, None)
......@@ -74,7 +71,7 @@ def editListBox(listbox_field, listbox):
else {}
for item_url, item_value in listbox.items():
if predicate_listbox:
if is_predicate_listbox:
item_value.update(global_attr)
context.setCriterion(item_url, **item_value)
continue
......
......@@ -56,16 +56,13 @@ def editListBox(listbox_field, listbox):
"""
if listbox is not None:
global_property_dict = {}
if context.isPredicate():
predicate_listbox = set(context.getCriterionPropertyList()) == set(listbox.keys())
else:
predicate_listbox = False
is_predicate_listbox = set(getattr(context, 'getCriterionPropertyList', lambda: [])()) == set(listbox.keys())
if listbox_field.has_value('global_attributes'):
hidden_attribute_list = [x[0] for x in listbox_field.get_value('global_attributes')]
for hidden_attribute in hidden_attribute_list:
global_property_dict[hidden_attribute] = getattr(request, hidden_attribute, None)
for item_url, listbox_item_dict in listbox.items():
if predicate_listbox:
if is_predicate_listbox:
listbox_item_dict.update(global_property_dict)
context.setCriterion(item_url, **listbox_item_dict)
continue
......
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