[Erp5-report] r33620 nicolas.dumazet - in /erp5/trunk/products/ERP5Form: ./ tests/
nobody at svn.erp5.org
nobody at svn.erp5.org
Thu Mar 11 09:54:51 CET 2010
Author: nicolas.dumazet
Date: Thu Mar 11 09:54:51 2010
New Revision: 33620
URL: http://svn.erp5.org?rev=33620&view=rev
Log:
Render Extra and CSS fields in Listbox lines
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=33620&r1=33619&r2=33620&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Form/ListBox.py [utf8] (original)
+++ erp5/trunk/products/ERP5Form/ListBox.py [utf8] Thu Mar 11 09:54:51 2010
@@ -2291,37 +2291,41 @@
except AttributeError:
pass
- if editable_field is not None and sql in editable_column_id_set:
+ if editable_field is not None:
# XXX what if the object does not have uid?
key = '%s_%s' % (editable_field.getId(), self.getUid())
- if has_error: # If there is any error on listbox, we should use what the user has typed
- display_value = None
- else:
- validated_value_dict = request.get(field_id, None)
- if validated_value_dict is None:
- # If this is neither an error nor a validated listbox
- # we should use the original value
- display_value = original_value
+ if sql in editable_column_id_set:
+ if has_error: # If there is any error on listbox, we should use what the user has typed
+ display_value = None
else:
- # If the listbox has been validated (ie. as it is the
- # case whenever a relation field displays a popup menu)
- # we have to use the value entered by the user
- display_value = None #
- if error_dict.has_key(key): # If error on current field, we should display message
- error_text = error_dict[key].error_text
- error_text = cgi.escape(error_text)
- if isinstance(error_text, str):
- error_mapping = getattr(error_dict[key], 'error_mapping', None)
- if error_mapping is not None:
- error_text = u'%s' % Message(domain=ui_domain,
- message=error_text,
- mapping=error_mapping)
+ validated_value_dict = request.get(field_id, None)
+ if validated_value_dict is None:
+ # If this is neither an error nor a validated listbox
+ # we should use the original value
+ display_value = original_value
else:
- error_text = u'%s' % Message(domain=ui_domain,
- message=error_text)
- error_message = u'<br />' + error_text
+ # If the listbox has been validated (ie. as it is the
+ # case whenever a relation field displays a popup menu)
+ # we have to use the value entered by the user
+ display_value = None #
+ if error_dict.has_key(key): # If error on current field, we should display message
+ error_text = error_dict[key].error_text
+ error_text = cgi.escape(error_text)
+ if isinstance(error_text, str):
+ error_mapping = getattr(error_dict[key], 'error_mapping', None)
+ if error_mapping is not None:
+ error_text = u'%s' % Message(domain=ui_domain,
+ message=error_text,
+ mapping=error_mapping)
+ else:
+ error_text = u'%s' % Message(domain=ui_domain,
+ message=error_text)
+ error_message = u'<br />' + error_text
+ else:
+ error_message = u''
else:
error_message = u''
+ display_value = original_value
# 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
Modified: erp5/trunk/products/ERP5Form/tests/testListBox.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Form/tests/testListBox.py?rev=33620&r1=33619&r2=33620&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Form/tests/testListBox.py [utf8] (original)
+++ erp5/trunk/products/ERP5Form/tests/testListBox.py [utf8] Thu Mar 11 09:54:51 2010
@@ -296,6 +296,48 @@
# Make sure that word is there
self.assertEqual(rendered_listbox.find(word) > 0, True)
+ def test_07_ExtraAndCssFieldsInIntegerField(self, quiet=0, run=run_all_test):
+ """
+ Check that css_class and extra fields are rendered when used in a
+ listbox_xxx line, using IntegerField for the check.
+ """
+ portal = self.getPortal()
+ portal.ListBoxZuite_reset()
+
+ # Reset listbox properties
+ listbox = portal.FooModule_viewFooList.listbox
+ listbox.ListBox_setPropertyList(
+ field_list_method = 'portal_catalog',
+ field_columns = ['extra | Check extra',],
+ )
+
+ form = portal.FooModule_viewFooList
+ form.manage_addField('listbox_extra', 'extra', 'IntegerField')
+ integerfield = form.listbox_extra
+
+ word = 'dummy_%s_to_check_for_in_listbox_test'
+ extra = word % "extra"
+ css_class = word % "css_class"
+ integerfield.values['extra'] = "alt='%s'" % extra
+ integerfield.values['css_class'] = css_class
+ integerfield.values['default'] = '42'
+
+ # Create an new empty object with a list property
+ foo_module = portal.foo_module
+ o = foo_module.newContent()
+
+ # Reindex
+ o.immediateReindexObject()
+
+ # Render the module in html
+ request = get_request()
+ request['here'] = portal.foo_module
+ rendered_listbox = listbox.render(REQUEST=request)
+
+ # Make sure that the extras and css_classes
+ self.assertTrue(extra in rendered_listbox)
+ self.assertTrue(css_class in rendered_listbox)
+
def test_ObjectSupport(self):
# make sure listbox supports rendering of simple objects
# the only requirement is that objects have a `uid` attribute which is a
More information about the Erp5-report
mailing list