[Erp5-report] r38268 ivan - in /erp5/trunk/products/ERP5Form: ListBox.py tests/testListBox.py
nobody at svn.erp5.org
nobody at svn.erp5.org
Fri Sep 10 14:46:18 CEST 2010
Author: ivan
Date: Fri Sep 10 14:46:16 2010
New Revision: 38268
URL: http://svn.erp5.org?rev=38268&view=rev
Log:
Fix a logical error which used listbox configuration to get default listbox style mode. Due to historical reasons this is wrong assumption and dynamic selections of columns must use system wide constant for this. This way we can define really a default list_style for listbox. Cover this with test.
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=38268&r1=38267&r2=38268&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Form/ListBox.py [utf8] (original)
+++ erp5/trunk/products/ERP5Form/ListBox.py [utf8] Fri Sep 10 14:46:16 2010
@@ -59,6 +59,8 @@ try:
except NameError:
from sets import Set as set
+DEFAULT_LISTBOX_DISPLAY_STYLE = 'table'
+
class MethodWrapper:
def __init__(self, context, method_name):
self.context = context
@@ -409,7 +411,7 @@ class ListBoxWidget(Widget.Widget):
title="Default display style",
description=(
"A default display style for listbox rendering."),
- default='table',
+ default=DEFAULT_LISTBOX_DISPLAY_STYLE,
required=0)
property_names.append('default_display_style')
@@ -1146,8 +1148,7 @@ class ListBoxRenderer:
default_listbox_display_style = self.getDefaultDisplayStyle()
listbox_display_style = self.getListboxDisplayStyle()
dynamic_column_list_override = (self.getDisplayedColumnIdList() != None)
- list_style_column_change_required = (default_listbox_display_style != listbox_display_style)
-
+ list_style_column_change_required = listbox_display_style not in ('', DEFAULT_LISTBOX_DISPLAY_STYLE,)
if dynamic_column_list_override:
# dynamically setting columns is supported
available_column = self.getAllColumnList()
Modified: erp5/trunk/products/ERP5Form/tests/testListBox.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Form/tests/testListBox.py?rev=38268&r1=38267&r2=38268&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Form/tests/testListBox.py [utf8] (original)
+++ erp5/trunk/products/ERP5Form/tests/testListBox.py [utf8] Fri Sep 10 14:46:16 2010
@@ -598,6 +598,29 @@ return []
self.assertEqual('thumbnail', getListBoxRenderer(listbox).getListboxDisplayStyle())
self.assertSameSet([('title', 'Title'), ('thumbnail', 'Thumbnail')],
getListBoxRenderer(listbox).getSelectedColumnList())
+
+ # set different than 'table' listbox default mode and check variations
+ listbox.ListBox_setPropertyList(
+ field_default_display_style='search',
+ field_style_columns=['title | thumbnail_Title',
+ 'thumbnail | thumbnail_Thumbnail',
+ 'getIconAsHTML | search_Icon',
+ 'getSummaryAsHTML | search_Summary',
+ 'B | rss_title',
+ 'C | rss_description'],)
+ request.set('list_style', 'search')
+ self.assertEqual('search', getListBoxRenderer(listbox).getListboxDisplayStyle())
+ self.assertSameSet([('getIconAsHTML', 'Icon'), ('getSummaryAsHTML', 'Summary')],
+ getListBoxRenderer(listbox).getSelectedColumnList())
+
+ request.set('list_style', 'thumbnail')
+ self.assertEqual('thumbnail', getListBoxRenderer(listbox).getListboxDisplayStyle())
+ self.assertSameSet([('title', 'Title'), ('thumbnail', 'Thumbnail')],
+ getListBoxRenderer(listbox).getSelectedColumnList())
+
+ request.set('list_style', 'table')
+ self.assertSameSet([('id', u'ID'), ('title', u'Title'), ('getQuantity', u'Quantity')],
+ getListBoxRenderer(listbox).getSelectedColumnList())
def test_suite():
More information about the Erp5-report
mailing list