Commit 727cdeff authored by Yoshinori Okuji's avatar Yoshinori Okuji

Add URL columns


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@1272 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 6cf64da8
...@@ -137,7 +137,7 @@ class ListBoxWidget(Widget.Widget): ...@@ -137,7 +137,7 @@ class ListBoxWidget(Widget.Widget):
""" """
property_names = Widget.Widget.property_names +\ property_names = Widget.Widget.property_names +\
['lines', 'columns', 'all_columns', 'search_columns', 'sort_columns', 'sort', ['lines', 'columns', 'all_columns', 'search_columns', 'sort_columns', 'sort',
'editable_columns', 'all_editable_columns', 'stat_columns', 'global_attributes', 'editable_columns', 'all_editable_columns', 'stat_columns', 'url_columns', 'global_attributes',
'list_method', 'stat_method', 'selection_name', 'list_method', 'stat_method', 'selection_name',
'meta_types', 'portal_types', 'default_params', 'meta_types', 'portal_types', 'default_params',
'search', 'select', 'search', 'select',
...@@ -346,6 +346,7 @@ class ListBoxWidget(Widget.Widget): ...@@ -346,6 +346,7 @@ class ListBoxWidget(Widget.Widget):
editable_columns = field.get_value('editable_columns') editable_columns = field.get_value('editable_columns')
all_editable_columns = field.get_value('all_editable_columns') all_editable_columns = field.get_value('all_editable_columns')
stat_columns = field.get_value('stat_columns') stat_columns = field.get_value('stat_columns')
url_columns = field.get_value('url_columns')
search_columns = field.get_value('search_columns') search_columns = field.get_value('search_columns')
sort_columns = field.get_value('sort_columns') sort_columns = field.get_value('sort_columns')
domain_tree = field.get_value('domain_tree') domain_tree = field.get_value('domain_tree')
...@@ -387,6 +388,9 @@ class ListBoxWidget(Widget.Widget): ...@@ -387,6 +388,9 @@ class ListBoxWidget(Widget.Widget):
for column in all_columns: for column in all_columns:
stat_columns.append((column[0], column[0])) stat_columns.append((column[0], column[0]))
if not url_columns:
url_columns = []
has_catalog_path = None has_catalog_path = None
for (k, v) in all_columns: for (k, v) in all_columns:
if k == 'catalog.path' or k == 'path': if k == 'catalog.path' or k == 'path':
...@@ -1050,6 +1054,9 @@ onChange="submitAction(this.form,'%s/portal_selections/setReportRoot')"> ...@@ -1050,6 +1054,9 @@ onChange="submitAction(this.form,'%s/portal_selections/setReportRoot')">
current_section_size = current_section[4] current_section_size = current_section[4]
object_list = current_section[3] object_list = current_section[3]
for i in range(start,end): for i in range(start,end):
# Set the selection index.
selection.edit(index = i)
# Make sure we go to the right section # Make sure we go to the right section
while current_section_base_index + current_section_size <= i: while current_section_base_index + current_section_size <= i:
current_section_base_index += current_section[4] current_section_base_index += current_section[4]
...@@ -1165,7 +1172,7 @@ onChange="submitAction(this.form,'%s/portal_selections/setReportRoot')"> ...@@ -1165,7 +1172,7 @@ onChange="submitAction(this.form,'%s/portal_selections/setReportRoot')">
except TypeError: except TypeError:
attribute_value = attribute_value() attribute_value = attribute_value()
except: except:
LOG('ListBox', 0, '', error=sys.exc_info()) LOG('ListBox', 0, 'Could not evaluate', error=sys.exc_info())
attribute_value = "Could not evaluate" attribute_value = "Could not evaluate"
#LOG('ListBox', 0, 'o = %s' % repr(dir(o))) #LOG('ListBox', 0, 'o = %s' % repr(dir(o)))
if type(attribute_value) is type(0.0): if type(attribute_value) is type(0.0):
...@@ -1200,6 +1207,23 @@ onChange="submitAction(this.form,'%s/portal_selections/setReportRoot')"> ...@@ -1200,6 +1207,23 @@ onChange="submitAction(this.form,'%s/portal_selections/setReportRoot')">
# Add item to list_result_item for list render format # Add item to list_result_item for list render format
if render_format == 'list': if render_format == 'list':
list_result_item.append(my_field._get_default(self.generate_field_key(), display_value, o)) list_result_item.append(my_field._get_default(self.generate_field_key(), display_value, o))
else:
# Check if url_columns defines a method to retrieve the URL.
url_method = None
for column in url_columns:
if sql == column[0]:
url_method = getattr(o, column[1], '')
break
if url_method is not None:
try:
object_url = url_method(brain = o, selection = selection)
list_body = list_body + \
("<td class=\"%s\" align=\"%s\"><a href=\"%s\">%s</a></td>" %
(td_css, td_align, object_url, attribute_value))
except:
LOG('ListBox', 0, 'Could not evaluate url_method %s' % column[1], error=sys.exc_info())
list_body = list_body + \
("<td class=\"%s\" align=\"%s\">%s</td>" % (td_css, td_align, attribute_value) )
else: else:
# Check if this object provides a specific URL method # Check if this object provides a specific URL method
url_method = getattr(o, 'getListItemUrl', None) url_method = getattr(o, 'getListItemUrl', None)
......
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