Mercurial > p > roundup > code
diff roundup/cgi/templating.py @ 6421:9c57f2814597
Fix issue2551122 (MultilinkHTMLProperty sorted method issue)
The sorted method of MultilinkHTMLProperty does a string sort even if
the property is an integer.
Fixed so that the orderprop for the linked class is used.
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Sun, 23 May 2021 18:00:55 -0400 |
| parents | 3dbf1bc5e567 |
| children | 91ae685405ba |
line wrap: on
line diff
--- a/roundup/cgi/templating.py Sun May 23 17:41:23 2021 -0400 +++ b/roundup/cgi/templating.py Sun May 23 18:00:55 2021 -0400 @@ -2624,19 +2624,31 @@ # 0 to sort to sort None first # 1 is used to sort the integer values. NoneCode = (2,0)[NoneFirst] + + value = list(self.__iter__()) + + # determine orderprop for property. + if value: + orderprop = value[0]._db.getclass(property).orderprop() + else: # return empty list, nothing to sort. + return value + def keyfunc(v): # Return tuples made of (group order (int), base python # type) to sort function. # Do not return v[property] as that returns an HTMLProperty # type/subtype that throws an exception when sorting # python type (int. str ...) against None. - val = v[property]._value - if val: - return (1, val) # val should be base python type - elif val is None: + prop = v[property] + if not prop._value: return (NoneCode, None) - value = list(self.__iter__()) + val = prop[orderprop]._value + + if val is None: # verify orderprop is set to a value + return (NoneCode, None) + return (1, val) # val should be base python type + value.sort(key=keyfunc, reverse=reverse) return value
