Mercurial > p > roundup > code
changeset 1169:7b448a2425fd
bugfix to (multi)link menu() label generation
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Wed, 18 Sep 2002 22:26:07 +0000 |
| parents | 94620e088e3a |
| children | af104fa52746 |
| files | CHANGES.txt roundup/cgi/templating.py |
| diffstat | 2 files changed, 30 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/CHANGES.txt Wed Sep 18 07:04:39 2002 +0000 +++ b/CHANGES.txt Wed Sep 18 22:26:07 2002 +0000 @@ -16,6 +16,7 @@ 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
--- a/roundup/cgi/templating.py Wed Sep 18 07:04:39 2002 +0000 +++ b/roundup/cgi/templating.py Wed Sep 18 22:26:07 2002 +0000 @@ -930,16 +930,25 @@ s = '' l.append(_('<option %svalue="-1">- no selection -</option>')%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('<option %svalue="%s">%s</option>'%(s, optionid, lab)) l.append('</select>') @@ -967,14 +976,21 @@ 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 @@ 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('<option %svalue="%s">%s</option>'%(s, optionid, lab)) l.append('</select>') @@ -1078,14 +1096,20 @@ l = ['<select multiple name="%s" size="%s">'%(self._name, height)] k = linkcl.labelprop(1) 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 in value or option in 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] + '...' if additional: @@ -1093,6 +1117,8 @@ for propname in additional: m.append(linkcl.get(optionid, propname)) lab = lab + ' (%s)'%', '.join(m) + + # and generate lab = cgi.escape(lab) l.append('<option %svalue="%s">%s</option>'%(s, optionid, lab)) @@ -1299,7 +1325,6 @@ d['env'] = e return ''' form: %(form)s -url: %(url)r base: %(base)r classname: %(classname)r template: %(template)r
