From b8dd5d4bdbfacd628ab295aeecbd516a25a9dea9 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Tue, 30 Apr 2013 13:48:51 +0530 Subject: [PATCH] [data import tool] [fix] fix in passing of additional input fields as params --- core/page/data_import_tool/data_import_tool.py | 11 +++++++---- public/js/wn/request.js | 4 ++-- public/js/wn/upload.js | 5 +++-- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/core/page/data_import_tool/data_import_tool.py b/core/page/data_import_tool/data_import_tool.py index 8d8d1fe126..7aeff6672d 100644 --- a/core/page/data_import_tool/data_import_tool.py +++ b/core/page/data_import_tool/data_import_tool.py @@ -176,8 +176,12 @@ def upload(): return columns + # extra input params + import json + params = json.loads(webnotes.form_dict.get("params") or '{}') + # header - rows = read_csv_content_from_uploaded_file(webnotes.form_dict.get("ignore_encoding_errors")) + rows = read_csv_content_from_uploaded_file(params.get("ignore_encoding_errors")) start_row = get_start_row() header = rows[:start_row] data = rows[start_row:] @@ -195,7 +199,7 @@ def upload(): webnotes.conn.begin() - overwrite = webnotes.form_dict.get('overwrite') + overwrite = params.get('overwrite') doctype_dl = webnotes.model.doctype.get(doctype) # delete child rows (if parenttype) @@ -226,8 +230,7 @@ def upload(): ret.append('Inserted row for %s at #%s' % (getlink(parenttype, doc.parent), unicode(doc.idx))) else: - ret.append(import_doc(d, doctype, overwrite, row_idx, - webnotes.form_dict.get("_submit"))) + ret.append(import_doc(d, doctype, overwrite, row_idx, params.get("_submit"))) except Exception, e: error = True ret.append('Error for row (#%d) %s : %s' % (row_idx, diff --git a/public/js/wn/request.js b/public/js/wn/request.js index b559d463eb..7e888e111b 100644 --- a/public/js/wn/request.js +++ b/public/js/wn/request.js @@ -85,7 +85,7 @@ wn.request.call = function(opts) { opts.error && opts.error(xhr) } }; - + if(opts.progress_bar) { var interval = null; $.extend(ajax_args, { @@ -109,7 +109,7 @@ wn.request.call = function(opts) { } }) } - + $.ajax(ajax_args); } diff --git a/public/js/wn/upload.js b/public/js/wn/upload.js index f559165d9a..a0de229eab 100644 --- a/public/js/wn/upload.js +++ b/public/js/wn/upload.js @@ -25,14 +25,15 @@ wn.upload = { } // add other inputs in the div as arguments + opts.args.params = {}; $upload.find("input[name]").each(function() { var key = $(this).attr("name"); var type = $(this).attr("type"); if(key!="filedata" && key!="file_url") { if(type === "checkbox") { - opts.args[key] = $(this).is(":checked"); + opts.args.params[key] = $(this).is(":checked"); } else { - opts.args[key] = $(this).val(); + opts.args.params[key] = $(this).val(); } } })