Merge branch 'master' of github.com:webnotes/wnframework

This commit is contained in:
Nabin Hait 2013-04-30 18:09:12 +05:30
commit b28190870a
8 changed files with 33 additions and 24 deletions

View file

@ -187,7 +187,10 @@ Thank you,<br>
'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"]:

View file

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

View file

@ -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']))

View file

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

View file

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

View file

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

View file

@ -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])

View file

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