Parcourir la source

[data import tool] [fix] fix in passing of additional input fields as params

version-14
Anand Doshi il y a 12 ans
Parent
révision
b8dd5d4bdb
3 fichiers modifiés avec 12 ajouts et 8 suppressions
  1. +7
    -4
      core/page/data_import_tool/data_import_tool.py
  2. +2
    -2
      public/js/wn/request.js
  3. +3
    -2
      public/js/wn/upload.js

+ 7
- 4
core/page/data_import_tool/data_import_tool.py Voir le fichier

@@ -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,


+ 2
- 2
public/js/wn/request.js Voir le fichier

@@ -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);
}



+ 3
- 2
public/js/wn/upload.js Voir le fichier

@@ -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();
}
}
})


Chargement…
Annuler
Enregistrer