Skip to content

Commit 35ec49a

Browse files
author
Richard Jones
committed
fixed templating menu() sort_on handling [SF#1221936]
1 parent 32a09df commit 35ec49a

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

CHANGES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ Fixed:
2121
- fix invocation of hasPermission from templating code (sf bug 1224172)
2222
- have 'roundup-admin security' display property restrictions (sf bug
2323
1222135)
24+
- fixed templating menu() sort_on handling (sf bug 1221936)
2425

2526

2627
2005-05-02 0.8.3

roundup/cgi/templating.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1637,7 +1637,9 @@ def menu(self, size=None, height=None, showid=0, additional=[],
16371637
"additional" lists properties which should be included in the
16381638
label
16391639
"sort_on" indicates the property to sort the list on as
1640-
(direction, property) where direction is '+' or '-'.
1640+
(direction, property) where direction is '+' or '-'. A
1641+
single string with the direction prepended may be used.
1642+
For example: ('-', 'order'), '+name'.
16411643
16421644
The remaining keyword arguments are used as conditions for
16431645
filtering the items in the list - they're passed as the
@@ -1657,13 +1659,16 @@ def menu(self, size=None, height=None, showid=0, additional=[],
16571659
if value is None:
16581660
s = 'selected="selected" '
16591661
l.append(self._('<option %svalue="-1">- no selection -</option>')%s)
1660-
if linkcl.getprops().has_key('order'):
1662+
if sort_on is not None:
1663+
if not isinstance(sort_on, tuple):
1664+
if sort_on[0] in '+-':
1665+
sort_on = (sort_on[0], sort_on[1:])
1666+
else:
1667+
sort_on = ('+', sort_on)
1668+
elif linkcl.getprops().has_key('order'):
16611669
sort_on = ('+', 'order')
16621670
else:
1663-
if sort_on is None:
1664-
sort_on = ('+', linkcl.labelprop())
1665-
else:
1666-
sort_on = ('+', sort_on)
1671+
sort_on = ('+', linkcl.labelprop())
16671672
options = linkcl.filter(None, conditions, sort_on, (None, None))
16681673

16691674
# make sure we list the current value if it's retired

0 commit comments

Comments
 (0)