comparison roundup/cgi/templating.py @ 3361:64cc03598c8a

fixed templating menu() sort_on handling [SF#1221936]
author Richard Jones <richard@users.sourceforge.net>
date Fri, 24 Jun 2005 05:42:21 +0000
parents 5c8822d10fdc
children 7bc1e9c42a26
comparison
equal deleted inserted replaced
3359:cf9149fd3c6d 3361:64cc03598c8a
1635 "height" is used to set the <select> tag's "size" attribute 1635 "height" is used to set the <select> tag's "size" attribute
1636 "showid" includes the item ids in the list labels 1636 "showid" includes the item ids in the list labels
1637 "additional" lists properties which should be included in the 1637 "additional" lists properties which should be included in the
1638 label 1638 label
1639 "sort_on" indicates the property to sort the list on as 1639 "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'.
1641 1643
1642 The remaining keyword arguments are used as conditions for 1644 The remaining keyword arguments are used as conditions for
1643 filtering the items in the list - they're passed as the 1645 filtering the items in the list - they're passed as the
1644 "filterspec" argument to a Class.filter() call. 1646 "filterspec" argument to a Class.filter() call.
1645 1647
1655 k = linkcl.labelprop(1) 1657 k = linkcl.labelprop(1)
1656 s = '' 1658 s = ''
1657 if value is None: 1659 if value is None:
1658 s = 'selected="selected" ' 1660 s = 'selected="selected" '
1659 l.append(self._('<option %svalue="-1">- no selection -</option>')%s) 1661 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'):
1661 sort_on = ('+', 'order') 1669 sort_on = ('+', 'order')
1662 else: 1670 else:
1663 if sort_on is None: 1671 sort_on = ('+', linkcl.labelprop())
1664 sort_on = ('+', linkcl.labelprop())
1665 else:
1666 sort_on = ('+', sort_on)
1667 options = linkcl.filter(None, conditions, sort_on, (None, None)) 1672 options = linkcl.filter(None, conditions, sort_on, (None, None))
1668 1673
1669 # make sure we list the current value if it's retired 1674 # make sure we list the current value if it's retired
1670 if value and value not in options: 1675 if value and value not in options:
1671 options.insert(0, value) 1676 options.insert(0, value)

Roundup Issue Tracker: http://roundup-tracker.org/