Mercurial > p > roundup > code
diff roundup/cgi/templating.py @ 6444:3ca8b6145167
issue2551122 - fixing order by a link/multilink broke other props
Fix to make sorting by a property that is a link or multilink
broke sorting by basic property types. This fixes it so both work.
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Sat, 26 Jun 2021 00:12:47 -0400 |
| parents | 32a04dc87b30 |
| children | 30358e334232 58bd05fbf350 |
line wrap: on
line diff
--- a/roundup/cgi/templating.py Sat Jun 19 15:02:44 2021 -0400 +++ b/roundup/cgi/templating.py Sat Jun 26 00:12:47 2021 -0400 @@ -2636,12 +2636,19 @@ value = list(self.__iter__()) - # determine orderprop for property. - if value: - orderprop = value[0]._db.getclass(property).orderprop() - else: # return empty list, nothing to sort. + if not value: + # return empty list, nothing to sort. return value + # determine orderprop for property if property is a link or multilink + prop = self._db.getclass(self._classname).getprops()[property] + if type(prop) in [hyperdb.Link, hyperdb.Multilink]: + orderprop = value[0]._db.getclass(prop.classname).orderprop() + sort_by_link = True + else: + orderprop = property + sort_by_link = False + def keyfunc(v): # Return tuples made of (group order (int), base python # type) to sort function. @@ -2652,7 +2659,10 @@ if not prop._value: return (NoneCode, None) - val = prop[orderprop]._value + if sort_by_link: + val = prop[orderprop]._value + else: + val = prop._value if val is None: # verify orderprop is set to a value return (NoneCode, None)
