diff options
author | Étienne Loks <etienne.loks@proxience.com> | 2015-10-06 14:49:10 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@proxience.com> | 2015-10-06 14:49:10 +0200 |
commit | dad03f626f1028daa44821a7d88551fec21ae88f (patch) | |
tree | 7db35133da25a55cfe1183260953aab882255309 /ishtar_common/views.py | |
parent | 4b1349b748e8dbd1ace541cc55562dba6bd9fe6f (diff) | |
download | Ishtar-dad03f626f1028daa44821a7d88551fec21ae88f.tar.bz2 Ishtar-dad03f626f1028daa44821a7d88551fec21ae88f.zip |
Grids: manage multiple values in the same column
Diffstat (limited to 'ishtar_common/views.py')
-rw-r--r-- | ishtar_common/views.py | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/ishtar_common/views.py b/ishtar_common/views.py index 10c62d465..efd7a9de1 100644 --- a/ishtar_common/views.py +++ b/ishtar_common/views.py @@ -525,9 +525,14 @@ def get_item(model, func_name, default_name, extra_request_keys=[], my_vals = [format_val(v) for v in vals] else: new_vals = [] - for idx, v in enumerate(vals): - new_vals.append("{}{}{}".format( - my_vals[idx], settings.JOINT, format_val(v))) + if not vals: + for idx, my_v in enumerate(my_vals): + new_vals.append(u"{}{}{}".format( + my_v, u' - ', '')) + else: + for idx, v in enumerate(vals): + new_vals.append(u"{}{}{}".format( + my_vals[idx], u' - ', format_val(v))) my_vals = new_vals[:] data.append(", ".join(my_vals) or u"") datas.append(data) @@ -563,9 +568,10 @@ def get_item(model, func_name, default_name, extra_request_keys=[], for idx, value in enumerate(data[1:]): if value: table_col = table_cols[idx] - if type(table_col) in (list, tuple): - table_col = table_col[0] - res[table_col.split('.')[-1]] = value + if type(table_col) not in (list, tuple): + table_col = [table_col] + k = "__".join([tc.split('.')[-1] for tc in table_col]) + res[k] = value rows.append(res) data = json.dumps({ "records": items_nb, |