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