From 6aa0ff50b282aae5c1b66059b237aa56bd81a00c Mon Sep 17 00:00:00 2001 From: mdipierro Date: Fri, 26 Jul 2013 03:03:49 -0500 Subject: [PATCH] fixed bug in sqlform.grid --- VERSION | 2 +- gluon/sqlhtml.py | 23 +++++++++++------------ 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/VERSION b/VERSION index c583da0d..26115f44 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -Version 2.6.0-development+timestamp.2013.07.25.08.13.15 +Version 2.6.0-development+timestamp.2013.07.26.03.03.00 diff --git a/gluon/sqlhtml.py b/gluon/sqlhtml.py index 52fd42a6..c0fd11d2 100644 --- a/gluon/sqlhtml.py +++ b/gluon/sqlhtml.py @@ -2621,25 +2621,24 @@ class SQLFORM(FORM): if isinstance(linked_tables, dict): for tbl in linked_tables.keys(): tb = db[tbl] + if isinstance(linked_tables[tbl], list) and len(linked_tables[tbl])==1: + linked_tables[tbl] = linked_tables[tbl][0] if isinstance(linked_tables[tbl], list): - if len(linked_tables[tbl]) > 1: - t = T('%s(%s)' %(tbl, fld)) - else: - t = T(tb._plural) - for fld in linked_tables[tbl]: - if fld not in db[tbl].fields: - raise ValueError('Field %s not in table' %fld) - args0 = tbl + '.' + fld - links.append( - lambda row, t=t, nargs=nargs, args0=args0: + for fld in linked_tables[tbl]: + if fld not in db[tbl].fields: + raise ValueError('Field %s not in table' %fld) + args0 = tbl + '.' + fld + t = T('%s(%s)' %(tbl, fld)) + links.append( + lambda row, t=t, nargs=nargs, args0=args0: A(SPAN(t), _class=trap_class(), _href=url( - args=[args0, row[id_field_name]]))) + args=[args0, row[id_field_name]]))) else: - t = T(tb._plural) fld = linked_tables[tbl] if fld not in db[tbl].fields: raise ValueError('Field %s not in table' %fld) args0 = tbl + '.' + fld + t = T(tb._plural) links.append( lambda row, t=t, nargs=nargs, args0=args0: A(SPAN(t), _class=trap_class(), _href=url(