/browse: Fix sorting on custom cols. Also specify sort order explicitly when sorting on boolean columns

This commit is contained in:
Kovid Goyal 2010-10-19 14:33:19 -06:00
parent 973afc0733
commit 7dc8e70b71
2 changed files with 7 additions and 1 deletions

View File

@ -816,6 +816,10 @@ class SortKeyGenerator(object):
if val is None:
val = ''
val = val.lower()
elif dt == 'bool':
val = {True: 1, False: 2, None: 3}.get(val, 3)
yield val
# }}}

View File

@ -7,7 +7,7 @@ __docformat__ = 'restructuredtext en'
import operator, os, json
from binascii import hexlify, unhexlify
from urllib import quote
from urllib import quote, unquote
import cherrypy
@ -482,6 +482,8 @@ class BrowseServer(object):
@Endpoint(sort_type='list')
def browse_matches(self, category=None, cid=None, list_sort=None):
if list_sort:
list_sort = unquote(list_sort)
if not cid:
raise cherrypy.HTTPError(404, 'invalid category id: %r'%cid)
categories = self.categories_cache()