[data import tool] [fix] fix in passing of additional input fields as params
This commit is contained in:
parent
661766f22f
commit
b8dd5d4bdb
3 changed files with 12 additions and 8 deletions
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue