diff --git a/core/doctype/profile/profile.py b/core/doctype/profile/profile.py index b1334a7873..10bdd86a8b 100644 --- a/core/doctype/profile/profile.py +++ b/core/doctype/profile/profile.py @@ -187,7 +187,10 @@ Thank you,
'product': startup.product_name, 'user_fullname': get_user_fullname(webnotes.session['user']) } - sendmail_md(self.doc.email, subject=subject, msg=txt % args) + + sender = webnotes.session.user != "Administrator" and webnotes.session.user or None + + sendmail_md(recipients=self.doc.email, sender=sender, subject=subject, msg=txt % args) def on_trash(self): if self.doc.name in ["Administrator", "Guest"]: diff --git a/core/doctype/system_console/system_console.js b/core/doctype/system_console/system_console.js index 462082017f..f9a89c4d30 100644 --- a/core/doctype/system_console/system_console.js +++ b/core/doctype/system_console/system_console.js @@ -26,7 +26,7 @@ cur_frm.cscript['server_python'] = function(doc, dt, dn) { $c_obj(make_doclist(doc.doctype, doc.name), 'execute_server', '', function(r, rt) { doc = locals[doc.doctype][doc.name]; if(r.exc) { - doc.response = r.exc; + doc.response = (r.exc || []).join("\n"); } else { doc.response = 'Worked!'.bold() } diff --git a/core/page/data_import_tool/data_import_tool.py b/core/page/data_import_tool/data_import_tool.py index 524b5feab3..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() + 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")=="on")) + 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, @@ -307,13 +310,10 @@ def delete_child_rows(rows, doctype): def import_doc(d, doctype, overwrite, row_idx, submit=False): """import main (non child) document""" - from webnotes.model.bean import Bean - if webnotes.conn.exists(doctype, d['name']): if overwrite: - doclist = webnotes.model.doc.get(doctype, d['name']) - doclist[0].fields.update(d) - bean = Bean(doclist) + bean = webnotes.bean(doctype, d['name']) + bean.doc.fields.update(d) if d.get("docstatus") == 1: bean.update_after_submit() else: @@ -323,12 +323,11 @@ def import_doc(d, doctype, overwrite, row_idx, submit=False): return 'Ignored row (#%d) %s (exists)' % (row_idx, getlink(doctype, d['name'])) else: - d['__islocal'] = 1 - dl = Bean([webnotes.model.doc.Document(fielddata = d)]) - dl.save() + bean = webnotes.bean([d]) + bean.insert() if submit: - dl.submit() + bean.submit() return 'Inserted row (#%d) %s' % (row_idx, getlink(doctype, - dl.doc.fields['name'])) + bean.doc.fields['name'])) 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 e21ab936b9..a0de229eab 100644 --- a/public/js/wn/upload.js +++ b/public/js/wn/upload.js @@ -25,10 +25,16 @@ 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") { - opts.args[key] = $(this).val(); + if(type === "checkbox") { + opts.args.params[key] = $(this).is(":checked"); + } else { + opts.args.params[key] = $(this).val(); + } } }) diff --git a/webnotes/__init__.py b/webnotes/__init__.py index d7d997d038..2d765d95dc 100644 --- a/webnotes/__init__.py +++ b/webnotes/__init__.py @@ -107,14 +107,14 @@ def errprint(msg): print repr(msg) from utils import cstr - error_log.append(repr(msg)) + error_log.append(cstr(msg)) def log(msg): if not request_method: import conf if getattr(conf, "logging", False): print repr(msg) - + from utils import cstr debug_log.append(cstr(msg)) diff --git a/webnotes/handler.py b/webnotes/handler.py index 74b3dae4c0..d8aa33164c 100755 --- a/webnotes/handler.py +++ b/webnotes/handler.py @@ -291,7 +291,8 @@ def make_logs(): import json, conf from webnotes.utils import cstr if webnotes.error_log: - webnotes.response['exc'] = json.dumps("\n".join([cstr(d) for d in webnotes.error_log])) + # webnotes.response['exc'] = json.dumps("\n".join([cstr(d) for d in webnotes.error_log])) + webnotes.response['exc'] = json.dumps([cstr(d) for d in webnotes.error_log]) if webnotes.message_log: webnotes.response['_server_messages'] = json.dumps([cstr(d) for d in webnotes.message_log]) diff --git a/webnotes/utils/datautils.py b/webnotes/utils/datautils.py index c106af0b25..0155d73abf 100644 --- a/webnotes/utils/datautils.py +++ b/webnotes/utils/datautils.py @@ -26,10 +26,10 @@ import json import csv, cStringIO from webnotes.utils import encode, cstr -def read_csv_content_from_uploaded_file(): +def read_csv_content_from_uploaded_file(ignore_encoding=False): from webnotes.utils.file_manager import get_uploaded_content fname, fcontent = get_uploaded_content() - return read_csv_content(fcontent) + return read_csv_content(fcontent, ignore_encoding) def read_csv_content_from_attached_file(doc): fileid = webnotes.conn.get_value("File Data", {"attached_to_doctype": doc.doctype,