changeset 6446:0a0aa4a506db

merge changes.txt date update
author John Rouillard <rouilj@ieee.org>
date Sat, 26 Jun 2021 20:53:40 -0400
parents 0c40c398e921 (current diff) 3ca8b6145167 (diff)
children 8f8f4988b856
files
diffstat 1 files changed, 15 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/roundup/cgi/templating.py	Sat Jun 19 23:20:35 2021 -0400
+++ b/roundup/cgi/templating.py	Sat Jun 26 20:53:40 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)

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