Commit dc6c4af0 authored by Kevin Deldycke's avatar Kevin Deldycke

This little modification correct the bug #56 ("switching to domain tree the...

This little modification correct the bug #56 ("switching to domain tree the first time shows all base categories").


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@3625 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 6989e03d
...@@ -72,6 +72,10 @@ def makeTreeBody(form, root_dict, domain_path, depth, total_depth, unfolded_list ...@@ -72,6 +72,10 @@ def makeTreeBody(form, root_dict, domain_path, depth, total_depth, unfolded_list
if total_depth is None: if total_depth is None:
total_depth = max(1, len(unfolded_list)) total_depth = max(1, len(unfolded_list))
# This two lines must correct the bug #56
if domain_path == ('portal_categories',):
return ''
if type(domain_path) is type('a'): domain_path = domain_path.split('/') if type(domain_path) is type('a'): domain_path = domain_path.split('/')
portal_categories = getattr(form, 'portal_categories', None) portal_categories = getattr(form, 'portal_categories', None)
...@@ -132,8 +136,8 @@ def makeTreeBody(form, root_dict, domain_path, depth, total_depth, unfolded_list ...@@ -132,8 +136,8 @@ def makeTreeBody(form, root_dict, domain_path, depth, total_depth, unfolded_list
return tree_body return tree_body
_parent_domain_mark = '__parent' _parent_domain_mark = '__parent'
def makeTreeList(here, form, root_dict, report_path, base_category, depth, unfolded_list, form_id, selection_name, report_depth, is_report_opened=1, sort_on = (('id', 'ASC'),)): def makeTreeList(here, form, root_dict, report_path, base_category, depth, unfolded_list, form_id, selection_name, report_depth, is_report_opened=1, sort_on = (('id', 'ASC'),)):
""" """
(object, is_pure_summary, depth, is_open, select_domain_dict) (object, is_pure_summary, depth, is_open, select_domain_dict)
...@@ -162,7 +166,7 @@ def makeTreeList(here, form, root_dict, report_path, base_category, depth, unfol ...@@ -162,7 +166,7 @@ def makeTreeList(here, form, root_dict, report_path, base_category, depth, unfol
# parent has a special treatment # parent has a special treatment
root = root_dict[base_category] = root_dict[None] = here root = root_dict[base_category] = root_dict[None] = here
report_path = report_path[1:] report_path = report_path[1:]
else: else:
root = root_dict[base_category] = root_dict[None] = portal_categories[base_category] root = root_dict[base_category] = root_dict[None] = portal_categories[base_category]
report_path = report_path[1:] report_path = report_path[1:]
if root is None and portal_domains is not None: if root is None and portal_domains is not None:
...@@ -198,7 +202,7 @@ def makeTreeList(here, form, root_dict, report_path, base_category, depth, unfol ...@@ -198,7 +202,7 @@ def makeTreeList(here, form, root_dict, report_path, base_category, depth, unfol
for sub_zo in o.searchFolder(sort_on=sort_on): for sub_zo in o.searchFolder(sort_on=sort_on):
sub_o = sub_zo.getObject() sub_o = sub_zo.getObject()
if sub_o is not None and hasattr(aq_base(root), 'objectValues'): if sub_o is not None and hasattr(aq_base(root), 'objectValues'):
exception_uid_list.append(sub_o.getUid()) exception_uid_list.append(sub_o.getUid())
tree_list += [(o, 1, depth, 1, selection_domain, exception_uid_list)] # Summary (open) tree_list += [(o, 1, depth, 1, selection_domain, exception_uid_list)] # Summary (open)
if is_report_opened : if is_report_opened :
tree_list += [(o, 0, depth, 0, selection_domain, exception_uid_list)] # List (contents, closed, must be strict selection) tree_list += [(o, 0, depth, 0, selection_domain, exception_uid_list)] # List (contents, closed, must be strict selection)
...@@ -214,8 +218,8 @@ def makeTreeList(here, form, root_dict, report_path, base_category, depth, unfol ...@@ -214,8 +218,8 @@ def makeTreeList(here, form, root_dict, report_path, base_category, depth, unfol
tree_list += [(o, 1, depth, 1, selection_domain, None)] # Summary (open) tree_list += [(o, 1, depth, 1, selection_domain, None)] # Summary (open)
if is_report_opened : if is_report_opened :
tree_list += [(o, 0, depth, 0, selection_domain, None)] # List (contents, closed, must be strict selection) tree_list += [(o, 0, depth, 0, selection_domain, None)] # List (contents, closed, must be strict selection)
tree_list += makeTreeList(here, form, new_root_dict, report_path, base_category, depth + 1, tree_list += makeTreeList(here, form, new_root_dict, report_path, base_category, depth + 1,
unfolded_list, form_id, selection_name, report_depth, unfolded_list, form_id, selection_name, report_depth,
is_report_opened=is_report_opened, sort_on=sort_on) is_report_opened=is_report_opened, sort_on=sort_on)
else: else:
tree_list += [(o, 1, depth, 0, selection_domain, None)] # Summary (closed) tree_list += [(o, 1, depth, 0, selection_domain, None)] # Summary (closed)
...@@ -446,29 +450,29 @@ class ListBoxWidget(Widget.Widget): ...@@ -446,29 +450,29 @@ class ListBoxWidget(Widget.Widget):
Returns Returns
""" """
if REQUEST is None: REQUEST=get_request() if REQUEST is None: REQUEST=get_request()
return self.render(field, key, value, REQUEST, render_format=render_format) return self.render(field, key, value, REQUEST, render_format=render_format)
def render(self, field, key, value, REQUEST, render_format='html'): def render(self, field, key, value, REQUEST, render_format='html'):
""" """
This is where most things happen. This method renders a list This is where most things happen. This method renders a list
of items of items
render_format allows to produce either HTML (default) render_format allows to produce either HTML (default)
or produce a generic 'list' format which can be converted by page templates or produce a generic 'list' format which can be converted by page templates
or dtml into various formats (ex. PDF, CSV, OpenOffice, etc.) or dtml into various formats (ex. PDF, CSV, OpenOffice, etc.)
the 'list' format includes additional metainformation the 'list' format includes additional metainformation
- depth in a report tree (ex. 0, 1, 2, etc.) - depth in a report tree (ex. 0, 1, 2, etc.)
- nature of the line (ex. stat or nonstat) - nature of the line (ex. stat or nonstat)
- identification of the tree (ex. relative_url) - identification of the tree (ex. relative_url)
- uid if any (to allow future import) - uid if any (to allow future import)
- etc. - etc.
which is intended to simplify operation with a spreadsheet or a pagetemplate which is intended to simplify operation with a spreadsheet or a pagetemplate
""" """
############################################################### ###############################################################
...@@ -525,9 +529,9 @@ class ListBoxWidget(Widget.Widget): ...@@ -525,9 +529,9 @@ class ListBoxWidget(Widget.Widget):
translate = portal_object.translation_service.translate translate = portal_object.translation_service.translate
# Make sure list_result_item is defined # Make sure list_result_item is defined
list_result_item = [] list_result_item = []
if render_format == 'list': if render_format == 'list':
# initialize the result # initialize the result
listboxline_list = [] listboxline_list = []
...@@ -591,7 +595,7 @@ class ListBoxWidget(Widget.Widget): ...@@ -591,7 +595,7 @@ class ListBoxWidget(Widget.Widget):
# Filter non searchable items # Filter non searchable items
sort_list = [] sort_list = []
fix_sort = 0 fix_sort = 0
for (k , v) in selection.sort_on: # XXX Access to selection - bad for (k , v) in selection.sort_on: # XXX Access to selection - bad
if k in sort_columns_id_list: if k in sort_columns_id_list:
sort_list.append((k,v)) sort_list.append((k,v))
else: else:
...@@ -619,7 +623,7 @@ class ListBoxWidget(Widget.Widget): ...@@ -619,7 +623,7 @@ class ListBoxWidget(Widget.Widget):
if len(domain_root_list): if len(domain_root_list):
domain_tree = 1 domain_tree = 1
report_tree = 0 report_tree = 0
else: else:
domain_tree = 0 domain_tree = 0
report_tree = 0 report_tree = 0
elif selection.report_tree_mode == 1: elif selection.report_tree_mode == 1:
...@@ -627,7 +631,7 @@ class ListBoxWidget(Widget.Widget): ...@@ -627,7 +631,7 @@ class ListBoxWidget(Widget.Widget):
if len(report_root_list): if len(report_root_list):
domain_tree = 0 domain_tree = 0
report_tree = 1 report_tree = 1
else: else:
domain_tree = 0 domain_tree = 0
report_tree = 0 report_tree = 0
...@@ -794,8 +798,8 @@ class ListBoxWidget(Widget.Widget): ...@@ -794,8 +798,8 @@ class ListBoxWidget(Widget.Widget):
else: else:
# No count method defined means that all objects must be retrieved. # No count method defined means that all objects must be retrieved.
count_method = None count_method = None
# Lookup the stat_method # Lookup the stat_method
if hasattr(stat_method, 'method_name'): if hasattr(stat_method, 'method_name'):
if stat_method.method_name == 'objectValues': if stat_method.method_name == 'objectValues':
...@@ -891,7 +895,7 @@ class ListBoxWidget(Widget.Widget): ...@@ -891,7 +895,7 @@ class ListBoxWidget(Widget.Widget):
start = params.get('list_start',0) start = params.get('list_start',0)
start = int(start) start = int(start)
start = max(start, 0) start = max(start, 0)
############################################################### ###############################################################
# #
# Build the report tree # Build the report tree
...@@ -909,14 +913,14 @@ class ListBoxWidget(Widget.Widget): ...@@ -909,14 +913,14 @@ class ListBoxWidget(Widget.Widget):
(portal_domains is not None and default_selection_report_path in portal_domains.objectIds()): (portal_domains is not None and default_selection_report_path in portal_domains.objectIds()):
pass pass
else: else:
default_selection_report_path = report_root_list[0][0] default_selection_report_path = report_root_list[0][0]
selection_report_path = selection.getReportPath(default = (default_selection_report_path,)) selection_report_path = selection.getReportPath(default = (default_selection_report_path,))
if report_depth is not None: if report_depth is not None:
selection_report_current = () selection_report_current = ()
else: else:
selection_report_current = selection.getReportList() selection_report_current = selection.getReportList()
report_tree_list = makeTreeList(here, form, None, selection_report_path, None, report_tree_list = makeTreeList(here, form, None, selection_report_path, None,
0, selection_report_current, form.id, selection_name, report_depth, 0, selection_report_current, form.id, selection_name, report_depth,
is_report_opened, sort_on=selection.sort_on) is_report_opened, sort_on=selection.sort_on)
# Update report list if report_depth was specified # Update report list if report_depth was specified
...@@ -929,7 +933,7 @@ class ListBoxWidget(Widget.Widget): ...@@ -929,7 +933,7 @@ class ListBoxWidget(Widget.Widget):
for s in report_tree_list: for s in report_tree_list:
# Prepare query by defining selection report object # Prepare query by defining selection report object
#if s[4] is not _parent_domain_mark: #if s[4] is not _parent_domain_mark:
selection.edit(report = s[4]) selection.edit(report = s[4])
if s[1]: if s[1]:
# Push new select_expression # Push new select_expression
original_select_expression = kw.get('select_expression') original_select_expression = kw.get('select_expression')
...@@ -961,7 +965,7 @@ class ListBoxWidget(Widget.Widget): ...@@ -961,7 +965,7 @@ class ListBoxWidget(Widget.Widget):
stat_context = s[0].asContext(**stat_result) stat_context = s[0].asContext(**stat_result)
stat_context.absolute_url = lambda x: s[0].absolute_url() stat_context.absolute_url = lambda x: s[0].absolute_url()
stat_context.domain_url = s[0].getRelativeUrl() stat_context.domain_url = s[0].getRelativeUrl()
section_title = s[0].getTitle() section_title = s[0].getTitle()
section_title = translate('content', section_title, section_title.decode('utf-8')) section_title = translate('content', section_title, section_title.decode('utf-8'))
if type(section_title) == type(u''): if type(section_title) == type(u''):
section_title = section_title.encode('utf-8') section_title = section_title.encode('utf-8')
...@@ -974,14 +978,14 @@ class ListBoxWidget(Widget.Widget): ...@@ -974,14 +978,14 @@ class ListBoxWidget(Widget.Widget):
#if s[4] is not _parent_domain_mark: #if s[4] is not _parent_domain_mark:
object_list = selection(method = list_method, context=here, REQUEST=REQUEST) object_list = selection(method = list_method, context=here, REQUEST=REQUEST)
#else: #else:
# object_list = [s[0]] # object_list = [s[0]]
else: else:
# If list_method is None, use already selected values. # If list_method is None, use already selected values.
#if s[4] is not _parent_domain_mark: #if s[4] is not _parent_domain_mark:
object_list = here.portal_selections.getSelectionValueList(selection_name, object_list = here.portal_selections.getSelectionValueList(selection_name,
context=here, REQUEST=REQUEST) context=here, REQUEST=REQUEST)
#else: #else:
# object_list = [s[0]] # object_list = [s[0]]
# # PERFORMANCE ? is len(object_list) fast enough ? # # PERFORMANCE ? is len(object_list) fast enough ?
exception_uid_list = s[5] exception_uid_list = s[5]
if exception_uid_list is not None: if exception_uid_list is not None:
...@@ -992,11 +996,11 @@ class ListBoxWidget(Widget.Widget): ...@@ -992,11 +996,11 @@ class ListBoxWidget(Widget.Widget):
if o.getUid() not in exception_uid_list: if o.getUid() not in exception_uid_list:
new_object_list.append(o) new_object_list.append(o)
object_list = new_object_list object_list = new_object_list
object_list_len = len(object_list) object_list_len = len(object_list)
if not s[1]: if not s[1]:
if show_stat: if show_stat:
report_sections += [ (None, 0, s[2], object_list, object_list_len, s[3], s[4], None, 0) ] report_sections += [ (None, 0, s[2], object_list, object_list_len, s[3], s[4], None, 0) ]
else: else:
stat_context = s[0].asContext() stat_context = s[0].asContext()
stat_context.absolute_url = lambda x: s[0].absolute_url() stat_context.absolute_url = lambda x: s[0].absolute_url()
stat_context.domain_url = s[0].getRelativeUrl() stat_context.domain_url = s[0].getRelativeUrl()
...@@ -1005,11 +1009,11 @@ class ListBoxWidget(Widget.Widget): ...@@ -1005,11 +1009,11 @@ class ListBoxWidget(Widget.Widget):
# If this domain is open # If this domain is open
report_sections += [ (s[0].getTitle(), 0, s[2], [object_list[0]], 1, s[3], s[4], stat_context, 0) ] report_sections += [ (s[0].getTitle(), 0, s[2], [object_list[0]], 1, s[3], s[4], stat_context, 0) ]
report_sections += [ (None, 0, s[2], object_list, object_list_len - 1, s[3], s[4], None, 1) ] report_sections += [ (None, 0, s[2], object_list, object_list_len - 1, s[3], s[4], None, 1) ]
else: else:
if exception_uid_list is not None: if exception_uid_list is not None:
# Display current parent domain # Display current parent domain
report_sections += [ (s[0].getTitle(), 0, s[2], [s[0]], 1, s[3], s[4], stat_context, 0) ] report_sections += [ (s[0].getTitle(), 0, s[2], [s[0]], 1, s[3], s[4], stat_context, 0) ]
else: else:
# No data to display # No data to display
report_sections += [ (s[0].getTitle(), 0, s[2], [None], 1, s[3], s[4], stat_context, 0) ] report_sections += [ (s[0].getTitle(), 0, s[2], [None], 1, s[3], s[4], stat_context, 0) ]
...@@ -1062,7 +1066,7 @@ class ListBoxWidget(Widget.Widget): ...@@ -1062,7 +1066,7 @@ class ListBoxWidget(Widget.Widget):
############################################################### ###############################################################
# XXX To avoid the difference of the string representations of int and long, # XXX To avoid the difference of the string representations of int and long,
# convert each element to a string. # convert each element to a string.
object_uid_list = [str(getattr(x, 'uid', None)) for x in object_list] object_uid_list = [str(getattr(x, 'uid', None)) for x in object_list]
object_uid_list.sort() object_uid_list.sort()
md5_string = md5.new(str(object_uid_list)).hexdigest() md5_string = md5.new(str(object_uid_list)).hexdigest()
...@@ -1220,16 +1224,16 @@ class ListBoxWidget(Widget.Widget): ...@@ -1220,16 +1224,16 @@ class ListBoxWidget(Widget.Widget):
title="%(flat_list_title)s" name="portal_selections/setFlatListMode:method" value="1" border="0" alt="img"/"> title="%(flat_list_title)s" name="portal_selections/setFlatListMode:method" value="1" border="0" alt="img"/">
""" % format_dict """ % format_dict
if len(report_root_list): if len(report_root_list):
header += """ header += """
<input type="image" src="%(portal_url_string)s/images/view_tree.png" id="report_list" <input type="image" src="%(portal_url_string)s/images/view_tree.png" id="report_list"
title="%(report_tree_title)s" name="portal_selections/setReportTreeMode:method" value="1" border="0" alt="img"/"> title="%(report_tree_title)s" name="portal_selections/setReportTreeMode:method" value="1" border="0" alt="img"/">
""" % format_dict """ % format_dict
if len(domain_root_list): if len(domain_root_list):
header += """ header += """
<input type="image" src="%(portal_url_string)s/images/view_choose.png" id="domain_list" <input type="image" src="%(portal_url_string)s/images/view_choose.png" id="domain_list"
title="%(domain_tree_title)s" name="portal_selections/setDomainTreeMode:method" value="1" border="0" alt="img"/"> title="%(domain_tree_title)s" name="portal_selections/setDomainTreeMode:method" value="1" border="0" alt="img"/">
""" % format_dict """ % format_dict
header += """ header += """
</td> </td>
<td width="100%%" valign="middle">&nbsp; <a href="%(list_action)s">%(field_title)s</a>: <td width="100%%" valign="middle">&nbsp; <a href="%(list_action)s">%(field_title)s</a>:
%(record_number)s - %(item_number)s %(record_number)s - %(item_number)s
...@@ -1335,7 +1339,7 @@ onChange="submitAction(this.form,'%s/portal_selections/setReportRoot')"> ...@@ -1335,7 +1339,7 @@ onChange="submitAction(this.form,'%s/portal_selections/setReportRoot')">
# In report mode, we may want to hide items, and only display stat lines. # In report mode, we may want to hide items, and only display stat lines.
depth_selector += """&nbsp;-&nbsp;<a href="%s/%s?selection_name=%s&selection_index=%s&is_report_opened:int=%s">%s</a>""" % \ depth_selector += """&nbsp;-&nbsp;<a href="%s/%s?selection_name=%s&selection_index=%s&is_report_opened:int=%s">%s</a>""" % \
(here.absolute_url(), form.id, current_selection_name, current_selection_index , 1 - is_report_opened, is_report_opened and 'Hide' or 'Show') (here.absolute_url(), form.id, current_selection_name, current_selection_index , 1 - is_report_opened, is_report_opened and 'Hide' or 'Show')
# Create the search row of the table with the name of the columns # Create the search row of the table with the name of the columns
if search: if search:
if report_tree: if report_tree:
...@@ -1366,13 +1370,13 @@ onChange="submitAction(this.form,'%s/portal_selections/setReportRoot')"> ...@@ -1366,13 +1370,13 @@ onChange="submitAction(this.form,'%s/portal_selections/setReportRoot')">
param = params.get(alias,'') param = params.get(alias,'')
if type(param) == type(''): if type(param) == type(''):
param = unicode(param, 'utf-8') param = unicode(param, 'utf-8')
search_field_id = 'search_%s_%s' % (field.id, alias) search_field_id = 'search_%s_%s' % (field.id, alias)
if form.has_field(search_field_id): if form.has_field(search_field_id):
# First look for a search field # First look for a search field
search_field = form.get_field(search_field_id) search_field = form.get_field(search_field_id)
search_field_html = search_field.render(value = param, key=alias) search_field_html = search_field.render(value = param, key=alias)
else: else:
# Then create default rendering # Then create default rendering
search_field_html = """<input name="%s" size="8" value="%s" />""" % (alias, param) search_field_html = """<input name="%s" size="8" value="%s" />""" % (alias, param)
list_search += """\ list_search += """\
<td class="DataB"> <td class="DataB">
...@@ -1409,13 +1413,13 @@ onChange="submitAction(this.form,'%s/portal_selections/setReportRoot')"> ...@@ -1409,13 +1413,13 @@ onChange="submitAction(this.form,'%s/portal_selections/setReportRoot')">
# Build Lines # Build Lines
list_body = '' list_body = ''
if render_format == 'list': if render_format == 'list':
# initialize the title line # initialize the title line
title_listboxline = ListBoxLine() title_listboxline = ListBoxLine()
title_listboxline.markTitleLine() title_listboxline.markTitleLine()
for cname in columns: for cname in columns:
title_listboxline.addColumn( cname[0], cname[1].encode('utf-8')) title_listboxline.addColumn( cname[0], cname[1].encode('utf-8'))
listboxline_list.append(title_listboxline) listboxline_list.append(title_listboxline)
section_index = 0 section_index = 0
current_section_base_index = 0 current_section_base_index = 0
...@@ -1437,7 +1441,7 @@ onChange="submitAction(this.form,'%s/portal_selections/setReportRoot')"> ...@@ -1437,7 +1441,7 @@ onChange="submitAction(this.form,'%s/portal_selections/setReportRoot')">
# Create a ListBoxLine object # Create a ListBoxLine object
current_listboxline = ListBoxLine() current_listboxline = ListBoxLine()
current_listboxline.markDataLine() current_listboxline.markDataLine()
# Set the selection index. # Set the selection index.
selection.edit(index = i) selection.edit(index = i)
...@@ -1451,7 +1455,7 @@ onChange="submitAction(this.form,'%s/portal_selections/setReportRoot')"> ...@@ -1451,7 +1455,7 @@ onChange="submitAction(this.form,'%s/portal_selections/setReportRoot')">
object_list = current_section[3] object_list = current_section[3]
stat_context = current_section[7] stat_context = current_section[7]
index_shift = current_section[8] index_shift = current_section[8]
is_summary = current_section[1] # Update summary type is_summary = current_section[1] # Update summary type
...@@ -1476,16 +1480,16 @@ onChange="submitAction(this.form,'%s/portal_selections/setReportRoot')"> ...@@ -1476,16 +1480,16 @@ onChange="submitAction(this.form,'%s/portal_selections/setReportRoot')">
section_name = current_section[0] section_name = current_section[0]
else: else:
section_name = '' section_name = ''
if current_section[5]: if current_section[5]:
if section_name != '': if section_name != '':
section_char = '-' section_char = '-'
list_body = list_body + \ list_body = list_body + \
"""<td class="%s" align="left" valign="middle"><a href="portal_selections/foldReport?report_url=%s&form_id=%s&list_selection_name=%s">%s%s%s</a></td> """<td class="%s" align="left" valign="middle"><a href="portal_selections/foldReport?report_url=%s&form_id=%s&list_selection_name=%s">%s%s%s</a></td>
""" % (td_css, getattr(stat_context,'domain_url',''), form.id, selection_name, '&nbsp;&nbsp;' * current_section[2], section_char, translate('content', section_name, default=section_name.decode('utf-8'))) """ % (td_css, getattr(stat_context,'domain_url',''), form.id, selection_name, '&nbsp;&nbsp;' * current_section[2], section_char, translate('content', section_name, default=section_name.decode('utf-8')))
if render_format == 'list': if render_format == 'list':
if is_summary: if is_summary:
current_listboxline.markSummaryLine() current_listboxline.markSummaryLine()
# XXX temporary correction (I dont some '' which havent signification) # XXX temporary correction (I dont some '' which havent signification)
...@@ -1503,8 +1507,8 @@ onChange="submitAction(this.form,'%s/portal_selections/setReportRoot')"> ...@@ -1503,8 +1507,8 @@ onChange="submitAction(this.form,'%s/portal_selections/setReportRoot')">
"""<td class="%s" align="left" valign="middle"><a href="portal_selections/unfoldReport?report_url=%s&form_id=%s&list_selection_name=%s">%s%s%s</a></td> """<td class="%s" align="left" valign="middle"><a href="portal_selections/unfoldReport?report_url=%s&form_id=%s&list_selection_name=%s">%s%s%s</a></td>
""" % (td_css, getattr(stat_context,'domain_url',''), form.id, selection_name, '&nbsp;&nbsp;' * current_section[2], section_char, translate('content', section_name, default=section_name.decode('utf-8'))) """ % (td_css, getattr(stat_context,'domain_url',''), form.id, selection_name, '&nbsp;&nbsp;' * current_section[2], section_char, translate('content', section_name, default=section_name.decode('utf-8')))
if render_format == 'list': if render_format == 'list':
if is_summary: if is_summary:
current_listboxline.markSummaryLine() current_listboxline.markSummaryLine()
# XXX temporary correction (I dont some '' which havent signification) # XXX temporary correction (I dont some '' which havent signification)
...@@ -1534,11 +1538,11 @@ onChange="submitAction(this.form,'%s/portal_selections/setReportRoot')"> ...@@ -1534,11 +1538,11 @@ onChange="submitAction(this.form,'%s/portal_selections/setReportRoot')">
list_body = list_body + \ list_body = list_body + \
"""<td class="%s" width="50" align="center" valign="middle">&nbsp;</td> """<td class="%s" width="50" align="center" valign="middle">&nbsp;</td>
""" % td_css """ % td_css
error_list = [] error_list = []
if render_format == 'list': if render_format == 'list':
if o is not None: if o is not None:
if selected == '': if selected == '':
current_listboxline.setObjectUid( o.uid ) current_listboxline.setObjectUid( o.uid )
...@@ -1550,11 +1554,11 @@ onChange="submitAction(this.form,'%s/portal_selections/setReportRoot')"> ...@@ -1550,11 +1554,11 @@ onChange="submitAction(this.form,'%s/portal_selections/setReportRoot')">
if o is None: if o is None:
# This line is an empty line used by reports without statistics # This line is an empty line used by reports without statistics
list_body += ('<td class=\"%s\">&nbsp;</td>' % td_css) * len(extended_columns) list_body += ('<td class=\"%s\">&nbsp;</td>' % td_css) * len(extended_columns)
else: else:
for cname in extended_columns: for cname in extended_columns:
# add attribute_original_value, because I need to know the type of the attribute # add attribute_original_value, because I need to know the type of the attribute
attribute_original_value = None attribute_original_value = None
sql = cname[0] # (sql, title, alias) sql = cname[0] # (sql, title, alias)
alias = cname[2] # (sql, title, alias) alias = cname[2] # (sql, title, alias)
if '.' in sql: if '.' in sql:
...@@ -1630,7 +1634,7 @@ onChange="submitAction(this.form,'%s/portal_selections/setReportRoot')"> ...@@ -1630,7 +1634,7 @@ onChange="submitAction(this.form,'%s/portal_selections/setReportRoot')">
#LOG('Look up accessor %s' % cname_id,0,'') #LOG('Look up accessor %s' % cname_id,0,'')
attribute_value = real_o.getProperty(property_id) attribute_value = real_o.getProperty(property_id)
attribute_original_value = attribute_value attribute_original_value = attribute_value
#LOG('Look up accessor %s' % cname_id,0,str(attribute_value)) #LOG('Look up accessor %s' % cname_id,0,str(attribute_value))
except: except:
attribute_value = getattr(real_o,property_id) attribute_value = getattr(real_o,property_id)
...@@ -1705,8 +1709,8 @@ onChange="submitAction(this.form,'%s/portal_selections/setReportRoot')"> ...@@ -1705,8 +1709,8 @@ onChange="submitAction(this.form,'%s/portal_selections/setReportRoot')">
cell_body = unicode(cell_body, 'utf-8') cell_body = unicode(cell_body, 'utf-8')
#LOG('ListBox', 0, 'cell_body = %r, error_message = %r' % (cell_body, error_message)) #LOG('ListBox', 0, 'cell_body = %r, error_message = %r' % (cell_body, error_message))
list_body += ('<td class=\"%s%s\">%s%s</td>' % (td_css, error_css, cell_body, error_message)) list_body += ('<td class=\"%s%s\">%s%s</td>' % (td_css, error_css, cell_body, error_message))
# 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':
# column_value = my_field._get_default(my_field.generate_field_key(), attribute_original_value, o) # column_value = my_field._get_default(my_field.generate_field_key(), attribute_original_value, o)
...@@ -1714,19 +1718,19 @@ onChange="submitAction(this.form,'%s/portal_selections/setReportRoot')"> ...@@ -1714,19 +1718,19 @@ onChange="submitAction(this.form,'%s/portal_selections/setReportRoot')">
# #column_value = unicode(column_value, 'utf-8') # #column_value = unicode(column_value, 'utf-8')
# column_value = column_value.encode('utf-8') # column_value = column_value.encode('utf-8')
# current_listboxline.addColumn(property_id , column_value) # current_listboxline.addColumn(property_id , column_value)
if render_format == 'list': if render_format == 'list':
# Make sure that attribute value is UTF-8 # Make sure that attribute value is UTF-8
attribute_value_tmp = attribute_original_value attribute_value_tmp = attribute_original_value
if type(attribute_value_tmp) == type(u''): if type(attribute_value_tmp) == type(u''):
attribute_value_tmp = attribute_original_value.encode('utf-8') attribute_value_tmp = attribute_original_value.encode('utf-8')
# XXX this is horrible, but it would be better without those &nbsp; .... # XXX this is horrible, but it would be better without those &nbsp; ....
if type(attribute_value_tmp) == type(''): if type(attribute_value_tmp) == type(''):
if 'nbsp' in attribute_value_tmp: if 'nbsp' in attribute_value_tmp:
attribute_value_tmp = None attribute_value_tmp = None
current_listboxline.addColumn( cname[0] , attribute_value_tmp) current_listboxline.addColumn( cname[0] , attribute_value_tmp)
else: else:
# Check if url_columns defines a method to retrieve the URL. # Check if url_columns defines a method to retrieve the URL.
url_method = None url_method = None
...@@ -1766,27 +1770,27 @@ onChange="submitAction(this.form,'%s/portal_selections/setReportRoot')"> ...@@ -1766,27 +1770,27 @@ onChange="submitAction(this.form,'%s/portal_selections/setReportRoot')">
except: except:
list_body = list_body + \ list_body = list_body + \
("<td class=\"%s\" align=\"%s\">%s</td>" % (td_css, td_align, attribute_value) ) ("<td class=\"%s\" align=\"%s\">%s</td>" % (td_css, td_align, attribute_value) )
if render_format == 'list': if render_format == 'list':
# Make sure that attribute value is UTF-8 # Make sure that attribute value is UTF-8
attribute_value_tmp = attribute_original_value attribute_value_tmp = attribute_original_value
if type(attribute_value_tmp) == type(u''): if type(attribute_value_tmp) == type(u''):
attribute_value_tmp = attribute_original_value.encode('utf-8') attribute_value_tmp = attribute_original_value.encode('utf-8')
# XXX this is horrible, but it would be better without those &nbsp; .... # XXX this is horrible, but it would be better without those &nbsp; ....
if type(attribute_value_tmp) == type(''): if type(attribute_value_tmp) == type(''):
if 'nbsp' in attribute_value_tmp: if 'nbsp' in attribute_value_tmp:
attribute_value_tmp = None attribute_value_tmp = None
current_listboxline.addColumn( cname[0] , attribute_value_tmp) current_listboxline.addColumn( cname[0] , attribute_value_tmp)
list_body = list_body + '</tr>' list_body = list_body + '</tr>'
if render_format == 'list': if render_format == 'list':
listboxline_list.append(current_listboxline) listboxline_list.append(current_listboxline)
############################################################### ###############################################################
# #
# Build statistics # Build statistics
...@@ -1800,15 +1804,15 @@ onChange="submitAction(this.form,'%s/portal_selections/setReportRoot')"> ...@@ -1800,15 +1804,15 @@ onChange="submitAction(this.form,'%s/portal_selections/setReportRoot')">
# Create a ListBoxLine object # Create a ListBoxLine object
current_listboxline = ListBoxLine() current_listboxline = ListBoxLine()
current_listboxline.markStatLine() current_listboxline.markStatLine()
kw['select_expression'] = select_expression kw['select_expression'] = select_expression
selection.edit( params = kw ) selection.edit( params = kw )
count_results = selection(method = stat_method, count_results = selection(method = stat_method,
context=here, REQUEST=REQUEST) context=here, REQUEST=REQUEST)
list_body = list_body + '<tr>' list_body = list_body + '<tr>'
if report_tree: if report_tree:
list_body += '<td class="Data">&nbsp;</td>' list_body += '<td class="Data">&nbsp;</td>'
if select: if select:
...@@ -1846,7 +1850,7 @@ onChange="submitAction(this.form,'%s/portal_selections/setReportRoot')"> ...@@ -1846,7 +1850,7 @@ onChange="submitAction(this.form,'%s/portal_selections/setReportRoot')">
list_body += '<td class="Data">' + str(value) + '</td>' list_body += '<td class="Data">' + str(value) + '</td>'
if render_format == 'list': if render_format == 'list':
# Make sure that attribute value is UTF-8 # Make sure that attribute value is UTF-8
value_tmp = value value_tmp = value
if type(value) == type(u''): if type(value) == type(u''):
...@@ -1856,7 +1860,7 @@ onChange="submitAction(this.form,'%s/portal_selections/setReportRoot')"> ...@@ -1856,7 +1860,7 @@ onChange="submitAction(this.form,'%s/portal_selections/setReportRoot')">
if type(value_tmp) == type(''): if type(value_tmp) == type(''):
if 'nbsp' in value_tmp: if 'nbsp' in value_tmp:
value_tmp = None value_tmp = None
current_listboxline.addColumn( column[0] , value_tmp ) current_listboxline.addColumn( column[0] , value_tmp )
else: else:
...@@ -1871,15 +1875,15 @@ onChange="submitAction(this.form,'%s/portal_selections/setReportRoot')"> ...@@ -1871,15 +1875,15 @@ onChange="submitAction(this.form,'%s/portal_selections/setReportRoot')">
list_body += '</tr>' list_body += '</tr>'
if render_format == 'list': if render_format == 'list':
listboxline_list.append(current_listboxline) listboxline_list.append(current_listboxline)
#LOG('ListBox', 0, 'header = %r, selection_list = %r, list_header = %r, list_search = %r, list_body = %r, footer = %r' % (header, selection_line, list_header, list_search, list_body, footer)) #LOG('ListBox', 0, 'header = %r, selection_list = %r, list_header = %r, list_search = %r, list_body = %r, footer = %r' % (header, selection_line, list_header, list_search, list_body, footer))
#LOG('ListBox', 0, 'header = %r, selection_list = %r, list_header = %r, list_search = %r, footer = %r' % (header, selection_line, list_header, list_search, footer)) #LOG('ListBox', 0, 'header = %r, selection_list = %r, list_header = %r, list_search = %r, footer = %r' % (header, selection_line, list_header, list_search, footer))
list_html = header + selection_line + list_header + list_search + list_body + footer list_html = header + selection_line + list_header + list_search + list_body + footer
if render_format == 'list': if render_format == 'list':
#listboxline_list.append(current_listboxline) #listboxline_list.append(current_listboxline)
LOG('ListBox', 0, 'listboxline_list: %s' % str(listboxline_list) ) LOG('ListBox', 0, 'listboxline_list: %s' % str(listboxline_list) )
return listboxline_list return listboxline_list
...@@ -2032,7 +2036,7 @@ class ListBoxValidator(Validator.Validator): ...@@ -2032,7 +2036,7 @@ class ListBoxValidator(Validator.Validator):
try: try:
value = my_field.validator.validate(my_field, key, REQUEST) # We need cell value = my_field.validator.validate(my_field, key, REQUEST) # We need cell
result[uid[4:]][sql] = value result[uid[4:]][sql] = value
except ValidationError, err: except ValidationError, err:
#LOG("ListBox ValidationError",0,str(err)) #LOG("ListBox ValidationError",0,str(err))
err.field_id = error_result_key err.field_id = error_result_key
errors.append(err) errors.append(err)
...@@ -2057,13 +2061,13 @@ class ListBoxValidator(Validator.Validator): ...@@ -2057,13 +2061,13 @@ class ListBoxValidator(Validator.Validator):
key = 'field_' + my_field.id + '_%s' % o.uid key = 'field_' + my_field.id + '_%s' % o.uid
error_result_key = my_field.id + '_%s' % o.uid error_result_key = my_field.id + '_%s' % o.uid
REQUEST.cell = o # We need cell REQUEST.cell = o # We need cell
try: try:
value = my_field.validator.validate(my_field, key, REQUEST) # We need cell value = my_field.validator.validate(my_field, key, REQUEST) # We need cell
error_result[error_result_key] = value error_result[error_result_key] = value
if not result.has_key(o.getUrl()): if not result.has_key(o.getUrl()):
result[o.getUrl()] = {} result[o.getUrl()] = {}
result[o.getUrl()][sql] = value result[o.getUrl()][sql] = value
except ValidationError, err: except ValidationError, err:
#LOG("ListBox ValidationError",0,str(err)) #LOG("ListBox ValidationError",0,str(err))
err.field_id = error_result_key err.field_id = error_result_key
errors.append(err) errors.append(err)
...@@ -2105,7 +2109,7 @@ class ListBoxLine: ...@@ -2105,7 +2109,7 @@ class ListBoxLine:
Initialize the line and set the default values Initialize the line and set the default values
Selected columns must be defined in parameter of listbox.render... Selected columns must be defined in parameter of listbox.render...
""" """
self.is_title_line = 0 self.is_title_line = 0
self.is_data_line = 1 self.is_data_line = 1
self.is_stat_line = 0 self.is_stat_line = 0
...@@ -2124,7 +2128,7 @@ class ListBoxLine: ...@@ -2124,7 +2128,7 @@ class ListBoxLine:
self.column_dict = {} self.column_dict = {}
self.column_id_list = [] self.column_id_list = []
security.declarePublic('__getitem__') security.declarePublic('__getitem__')
def __getitem__(self, column_id): def __getitem__(self, column_id):
return getColumnProperty(self, column_id) return getColumnProperty(self, column_id)
...@@ -2177,21 +2181,21 @@ class ListBoxLine: ...@@ -2177,21 +2181,21 @@ class ListBoxLine:
Set content of the line to 'StatLine' Set content of the line to 'StatLine'
""" """
self.setListboxLineContentMode('StatLine') self.setListboxLineContentMode('StatLine')
security.declarePublic('isStatLine') security.declarePublic('isStatLine')
def isStatLine(self): def isStatLine(self):
""" """
Returns 1 is this line contains no data but only stats Returns 1 is this line contains no data but only stats
""" """
return self.is_stat_line return self.is_stat_line
#security.declarePublic('View') #security.declarePublic('View')
def markDataLine(self): def markDataLine(self):
""" """
Set content of the line to 'DataLine' Set content of the line to 'DataLine'
""" """
self.setListboxLineContentMode('DataLine') self.setListboxLineContentMode('DataLine')
security.declarePublic('isDataLine') security.declarePublic('isDataLine')
def isDataLine(self): def isDataLine(self):
""" """
...@@ -2227,7 +2231,7 @@ class ListBoxLine: ...@@ -2227,7 +2231,7 @@ class ListBoxLine:
Returns 1 is this line is checked Returns 1 is this line is checked
""" """
return self.getConfigProperty('is_checked') return self.getConfigProperty('is_checked')
#security.declarePublic('View') #security.declarePublic('View')
def setObjectUid(self, object_uid): def setObjectUid(self, object_uid):
""" """
...@@ -2242,7 +2246,7 @@ class ListBoxLine: ...@@ -2242,7 +2246,7 @@ class ListBoxLine:
Get the uid of the object related to the line Get the uid of the object related to the line
""" """
return self.getConfigProperty('uid') return self.getConfigProperty('uid')
#security.declarePublic('View') #security.declarePublic('View')
def setSectionName(self, section_name): def setSectionName(self, section_name):
""" """
...@@ -2266,7 +2270,7 @@ class ListBoxLine: ...@@ -2266,7 +2270,7 @@ class ListBoxLine:
default value is 0 and means no depth default value is 0 and means no depth
""" """
self.setConfigProperty('section_depth',depth) self.setConfigProperty('section_depth',depth)
security.declarePublic('getSectionDepth') security.declarePublic('getSectionDepth')
def getSectionDepth(self): def getSectionDepth(self):
""" """
...@@ -2274,26 +2278,26 @@ class ListBoxLine: ...@@ -2274,26 +2278,26 @@ class ListBoxLine:
0 means no depth 0 means no depth
""" """
return self.getConfigProperty('section_depth') return self.getConfigProperty('section_depth')
#security.declarePublic('View') #security.declarePublic('View')
def setSectionFolded(self, is_section_folded): def setSectionFolded(self, is_section_folded):
""" """
Set the section mode of this line to 'Folded' if is_section_folded=1 Set the section mode of this line to 'Folded' if is_section_folded=1
""" """
self.is_section_folded = is_section_folded self.is_section_folded = is_section_folded
security.declarePublic('isSectionFolded') security.declarePublic('isSectionFolded')
def isSectionFolded(self): def isSectionFolded(self):
""" """
Returns 1 if section is in 'Folded' Mode Returns 1 if section is in 'Folded' Mode
""" """
return self.is_section_folded return self.is_section_folded
#security.declarePublic('View') #security.declarePublic('View')
def addColumn(self, column_id, column_value): def addColumn(self, column_id, column_value):
""" """
Add a new column Add a new column
""" """
self.column_dict[column_id] = column_value self.column_dict[column_id] = column_value
self.column_id_list.append(column_id) self.column_id_list.append(column_id)
...@@ -2309,19 +2313,19 @@ class ListBoxLine: ...@@ -2309,19 +2313,19 @@ class ListBoxLine:
security.declarePublic('getColumnPropertyList') security.declarePublic('getColumnPropertyList')
def getColumnPropertyList(self, column_id_list = None): def getColumnPropertyList(self, column_id_list = None):
""" """
Returns a list of the property Returns a list of the property
column_id_list selects the column_id returned column_id_list selects the column_id returned
""" """
if column_id_list == None: if column_id_list == None:
column_id_list = self.column_id_list column_id_list = self.column_id_list
if self.isTitleLine(): if self.isTitleLine():
config_column = [None] * len(self.config_display_list) config_column = [None] * len(self.config_display_list)
else: else:
config_column = [self.config_dict[column_id] for column_id in self.config_display_list] config_column = [self.config_dict[column_id] for column_id in self.config_display_list]
return config_column + [self.column_dict[column_id] for column_id in column_id_list] return config_column + [self.column_dict[column_id] for column_id in column_id_list]
security.declarePublic('getColumnItemList') security.declarePublic('getColumnItemList')
...@@ -2330,10 +2334,10 @@ class ListBoxLine: ...@@ -2330,10 +2334,10 @@ class ListBoxLine:
Returns a list of property tuple Returns a list of property tuple
column_id_list selects the column_id returned column_id_list selects the column_id returned
""" """
if column_id_list == None: if column_id_list == None:
column_id_list = self.column_id_list column_id_list = self.column_id_list
""" """
if self.isTitleLine(): if self.isTitleLine():
config_column = [None] * len(self.config_display_list) config_column = [None] * len(self.config_display_list)
...@@ -2341,9 +2345,9 @@ class ListBoxLine: ...@@ -2341,9 +2345,9 @@ class ListBoxLine:
config_column = [(config_id, self.config_dict[column_id]) for config_id in self.config_display_list] config_column = [(config_id, self.config_dict[column_id]) for config_id in self.config_display_list]
""" """
config_column = [(config_id, self.config_dict[config_id]) for config_id in self.config_display_list] config_column = [(config_id, self.config_dict[config_id]) for config_id in self.config_display_list]
return config_column + [(column_id , self.column_dict[column_id]) for column_id in column_id_list] return config_column + [(column_id , self.column_dict[column_id]) for column_id in column_id_list]
security.declarePublic('setListboxLineDisplayListMode') security.declarePublic('setListboxLineDisplayListMode')
def setListboxLineDisplayListMode(self, display_list): def setListboxLineDisplayListMode(self, display_list):
""" """
...@@ -2352,7 +2356,7 @@ class ListBoxLine: ...@@ -2352,7 +2356,7 @@ class ListBoxLine:
Default value of display_list is [] Default value of display_list is []
""" """
self.config_display_list = display_list self.config_display_list = display_list
InitializeClass(ListBoxLine) InitializeClass(ListBoxLine)
allow_class(ListBoxLine) allow_class(ListBoxLine)
......
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