From 9f9e2ed87171627a4c5added460b07f79287b89c Mon Sep 17 00:00:00 2001 From: richard Date: Wed, 18 Sep 2002 22:26:07 +0000 Subject: [PATCH] bugfix to (multi)link menu() label generation git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@1193 57a73879-2fb5-44c3-a270-3262357dd7e2 --- CHANGES.txt | 1 + roundup/cgi/templating.py | 33 +++++++++++++++++++++++++++++---- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index a85ae01..9caa945 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -16,6 +16,7 @@ are given with the most recent entry first. backends - we now verify instance attributes on instance open and throw a useful error if they're not all there +- sf 611217 ] menu() has problems when labelprop==None 2002-09-13 0.5.0 beta2 diff --git a/roundup/cgi/templating.py b/roundup/cgi/templating.py index 5ab27bd..f78313b 100644 --- a/roundup/cgi/templating.py +++ b/roundup/cgi/templating.py @@ -930,16 +930,25 @@ class LinkHTMLProperty(HTMLProperty): s = '' l.append(_('')%s) for optionid in options: - option = linkcl.get(optionid, k) + # get the option value, and if it's None use an empty string + option = linkcl.get(optionid, k) or '' + + # figure if this option is selected s = '' if optionid == self._value: s = 'selected ' + + # figure the label if showid: lab = '%s%s: %s'%(self._prop.classname, optionid, option) else: lab = option + + # truncate if it's too long if size is not None and len(lab) > size: lab = lab[:size-3] + '...' + + # and generate lab = cgi.escape(lab) l.append(''%(s, optionid, lab)) l.append('') @@ -967,14 +976,21 @@ class LinkHTMLProperty(HTMLProperty): sort_on = ('+', linkcl.labelprop()) options = linkcl.filter(None, conditions, sort_on, (None, None)) for optionid in options: - option = linkcl.get(optionid, k) + # get the option value, and if it's None use an empty string + option = linkcl.get(optionid, k) or '' + + # figure if this option is selected s = '' if value in [optionid, option]: s = 'selected ' + + # figure the label if showid: lab = '%s%s: %s'%(self._prop.classname, optionid, option) else: lab = option + + # truncate if it's too long if size is not None and len(lab) > size: lab = lab[:size-3] + '...' if additional: @@ -982,6 +998,8 @@ class LinkHTMLProperty(HTMLProperty): for propname in additional: m.append(linkcl.get(optionid, propname)) lab = lab + ' (%s)'%', '.join(map(str, m)) + + # and generate lab = cgi.escape(lab) l.append(''%(s, optionid, lab)) l.append('') @@ -1078,14 +1096,20 @@ class MultilinkHTMLProperty(HTMLProperty): l = ['