minor refactoring in grid(orderby)

This commit is contained in:
mdipierro
2015-05-06 08:56:56 -05:00
parent 6e2f9ad043
commit 6f91fdd833
2 changed files with 10 additions and 13 deletions
+9 -12
View File
@@ -2070,18 +2070,15 @@ class SQLFORM(FORM):
# is unique and usually indexed. See issue #679 # is unique and usually indexed. See issue #679
if not orderby: if not orderby:
orderby = field_id orderby = field_id
else: elif isinstance(orderby, list):
if isinstance(orderby, Expression): orderby = map(lambda a,b: a|b, orderby)
if orderby.first: elif isinstance(orderby, Field) and orderby is not field_id:
# here we're with a DESC order on a field # here we're with an ASC order on a field stored as orderby
# stored as orderby.first orderby = orderby | field_id
if orderby.first is not field_id: elif (isinstance(orderby, Expression) and
orderby = orderby | field_id orderby.first and orderby.first is not field_id):
else: # here we're with a DESC order on a field stored as orderby.first
# here we're with an ASC order on a field orderby = orderby | field_id
# stored as orderby
if orderby is not field_id:
orderby = orderby | field_id
return orderby return orderby
def url(**b): def url(**b):