From: jlgijsbers Date: Thu, 20 Nov 2003 15:20:21 +0000 (+0000) Subject: - Always sort MultilinkHTMLProperty in the correct order, usually X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=e368c1de72aca5320ae65e1a4136de8e79860083;p=roundup.git - Always sort MultilinkHTMLProperty in the correct order, usually alphabetically (sf feature 790512). - Extract find_sort_key method. - Use nested scopes in make_sort_function. git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@2000 57a73879-2fb5-44c3-a270-3262357dd7e2 --- diff --git a/CHANGES.txt b/CHANGES.txt index 8c1c007..d4555d5 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -15,6 +15,8 @@ Feature: - Existing trackers (ie. live ones) may be used as templates for new trackers - the TEMPLATE-INFO.txt name entry has the tracker's dir name appended (so the demo tracker's template name is "classic-demo") +- Always sort MultilinkHTMLProperty in the correct order, usually + alphabetically (sf feature 790512). Fixed: - mysql documentation fixed to note requirement of 4.0+ and InnoDB @@ -55,7 +57,7 @@ Fixed: - Added note to upgrading doc for detectors fix in 0.6.2 - Added script to help migrating queries from pre-0.6 trackers - Fixed "documentation" of getnodeids in roundup.hyperdb -- Added flush() to DevNull (sf bug #835365) +- Added flush() to DevNull (sf bug 835365) - Fixed javascript for help window for only one checkbox case - Date arithmetic was utterly broken, and has been for a long time. Date +/- Interval now works, and Date - Date also works (produces diff --git a/roundup/cgi/templating.py b/roundup/cgi/templating.py index 062462b..1c461bf 100644 --- a/roundup/cgi/templating.py +++ b/roundup/cgi/templating.py @@ -1,3 +1,5 @@ +from __future__ import nested_scopes + import sys, cgi, urllib, os, re, os.path, time, errno, mimetypes from roundup import hyperdb, date, rcsv @@ -1193,9 +1195,6 @@ class LinkHTMLProperty(HTMLProperty): ''' value = self._value - # sort function - sortfunc = make_sort_function(self._db, self._prop.classname) - linkcl = self._db.getclass(self._prop.classname) l = [''%(self._formname, height)] k = linkcl.labelprop(1) @@ -1386,14 +1381,17 @@ def make_sort_function(db, classname): '''Make a sort function for a given class ''' linkcl = db.getclass(classname) - if linkcl.getprops().has_key('order'): - sort_on = 'order' - else: - sort_on = linkcl.labelprop() - def sortfunc(a, b, linkcl=linkcl, sort_on=sort_on): + sort_on = find_sort_key(linkcl) + def sortfunc(a, b): return cmp(linkcl.get(a, sort_on), linkcl.get(b, sort_on)) return sortfunc +def find_sort_key(linkcl): + if linkcl.getprops().has_key('order'): + return 'order' + else: + return linkcl.labelprop() + def handleListCGIValue(value): ''' Value is either a single item or a list of items. Each item has a .value that we're actually interested in.