[Erp5-report] r33704 nicolas.dumazet - in /erp5/trunk/products/ERP5Form: ./ tests/
nobody at svn.erp5.org
nobody at svn.erp5.org
Mon Mar 15 03:35:27 CET 2010
Author: nicolas.dumazet
Date: Mon Mar 15 03:35:25 2010
New Revision: 33704
URL: http://svn.erp5.org?rev=33704&view=rev
Log:
There's no precedence for listbox cell configuration. It's a boolean AND:
isEditable(listbox "field" cell) <=>
isEditable(listbox_field) AND ("field" in listbox.editable_columns)
Modified:
erp5/trunk/products/ERP5Form/ListBox.py
erp5/trunk/products/ERP5Form/tests/testListBox.py
Modified: erp5/trunk/products/ERP5Form/ListBox.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Form/ListBox.py?rev=33704&r1=33703&r2=33704&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Form/ListBox.py [utf8] (original)
+++ erp5/trunk/products/ERP5Form/ListBox.py [utf8] Mon Mar 15 03:35:25 2010
@@ -2330,18 +2330,19 @@
display_value = original_value
enabled = editable_field.get_value('enabled', REQUEST=request)
+ editable = editable_field.get_value('editable', REQUEST=request)
if enabled:
# We need a way to pass the current line object (ie. brain) to the
# field which is being displayed. Since the render_view API did not
# permit this, we use the 'cell' value to pass the line object.
request.set('cell', brain)
- # Listbox 'editable' configuration should take precedence over
- # individual field configuration
+ # Field is editable only if listbox lists it in editable columns AND
+ # if listbox_field is editable
cell_html = editable_field.render(
value=display_value,
REQUEST=request,
key=key,
- editable=listbox_defines_column_as_editable,
+ editable=listbox_defines_column_as_editable and editable,
)
if isinstance(cell_html, str):
cell_html = unicode(cell_html, encoding)
@@ -2351,7 +2352,7 @@
if url is None:
html = cell_html + error_message
else:
- if editable_field.get_value('editable', REQUEST=request):
+ if editable:
html = u'%s' % cell_html
else:
html = u'<a href="%s">%s</a>' % (url, cell_html)
Modified: erp5/trunk/products/ERP5Form/tests/testListBox.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Form/tests/testListBox.py?rev=33704&r1=33703&r2=33704&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Form/tests/testListBox.py [utf8] (original)
+++ erp5/trunk/products/ERP5Form/tests/testListBox.py [utf8] Mon Mar 15 03:35:25 2010
@@ -378,34 +378,49 @@
self._helperExtraAndCssInListboxLine("LinesField", True)
self._helperExtraAndCssInListboxLine("LinesField", False)
- def test_09_editablePropertyPrecedence(self):
- """
- When listbox's editable column and listbox_xx's editable property
- conflict, the listbox editable column choice should take over.
+ def test_09_editablePropertyConfiguration(self):
+ """
+ Test editable behavior of delegated columns.
+ A column is editable if and only if listbox_foo is editable AND foo is
+ in the editable columns of the listbox.
For example, if listbox_foo is defined as editable, without
having column "foo" listed as editable in the listbox, the field should
not be rendered as editable
"""
- portal = self.getPortal()
- portal.ListBoxZuite_reset()
-
- field_name = 'noneditable'
- field_id = 'listbox_noneditable'
+ self._helperEditableColumn(True, True, True)
+ self._helperEditableColumn(False, False, False)
+ self._helperEditableColumn(True, False, False)
+ self._helperEditableColumn(False, True, False)
+
+ def _helperEditableColumn(self, editable_in_listbox, editable_in_line,
+ expected_editable):
+ portal = self.getPortal()
+ portal.ListBoxZuite_reset()
+
+ field_name = 'editableproperty_%s_%s' \
+ % (editable_in_listbox, editable_in_line)
+ field_name = field_name.lower()
+ field_id = 'listbox_%s' % field_name
# Reset listbox properties
listbox = portal.FooModule_viewFooList.listbox
- listbox.ListBox_setPropertyList(
+ kw = dict(
field_list_method = 'portal_catalog',
field_columns = ['%s | Check extra' % field_name,],
)
+ if editable_in_listbox:
+ kw['field_editable_columns'] = '%s | Check extra' % field_name
+
+ listbox.ListBox_setPropertyList(**kw)
+
form = portal.FooModule_viewFooList
form.manage_addField(field_id, field_name, "StringField")
field = getattr(form, field_id)
field.values['default'] = '42'
- field.values['editable'] = True
+ field.values['editable'] = editable_in_line
form.groups['bottom'].remove(field_id)
form.groups['hidden'].append(field_id)
@@ -428,7 +443,10 @@
'//input[starts-with(@name, $name)]',
name='field_%s_' % field_id,
)
- self.assertEquals(len(editable_field_list), 0)
+
+ msg = "editable_in_listbox: %s, editable_in_line: %s" \
+ % (editable_in_listbox, editable_in_line)
+ self.assertEquals(len(editable_field_list) == 1, expected_editable, msg)
def test_ObjectSupport(self):
# make sure listbox supports rendering of simple objects
More information about the Erp5-report
mailing list