diff --git a/js/core.min.js b/js/core.min.js index fda315ba59..17f19ad365 100644 --- a/js/core.min.js +++ b/js/core.min.js @@ -270,7 +270,8 @@ return;} if(r.server_messages){r.server_messages=JSON.parse(r.server_messages) msgprint(r.server_messages);} if(r.exc){r.exc=JSON.parse(r.exc);if(r.exc instanceof Array){$.each(r.exc,function(i,v){if(v)console.log(v);})}else{console.log(r.exc);}};if(r['403']){wn.container.change_to('403');} -if(r.docs){LocalDB.sync(r.docs);}} +if(r.docs){LocalDB.sync(r.docs);} +wn.last_response=r;} wn.request.call=function(opts){wn.request.prepare(opts);var ajax_args={url:opts.url||wn.request.url,data:opts.args,type:opts.type||'POST',dataType:opts.dataType||'json',success:function(r,xhr){wn.request.cleanup(opts,r);opts.success&&opts.success(r,xhr.responseText);},error:function(xhr,textStatus){wn.request.cleanup(opts,{});show_alert('Unable to complete request: '+textStatus) opts.error&&opts.error(xhr)}};if(opts.progress_bar){var interval=null;$.extend(ajax_args,{xhr:function(){var xhr=jQuery.ajaxSettings.xhr();interval=setInterval(function(){if(xhr.readyState>2){var total=parseInt(xhr.getResponseHeader('Original-Length')||0)||parseInt(xhr.getResponseHeader('Content-Length'));var completed=parseInt(xhr.responseText.length);var percent=(100.0/total*completed).toFixed(2);opts.progress_bar.css('width',(percent<10?10:percent)+'%');}},50);wn.last_xhr=xhr;return xhr;},complete:function(){opts.progress_bar.css('width','100%');clearInterval(interval);}})} $.ajax(ajax_args);} diff --git a/js/wn/request.js b/js/wn/request.js index 15d543a07c..47b383238c 100644 --- a/js/wn/request.js +++ b/js/wn/request.js @@ -89,6 +89,8 @@ wn.request.cleanup = function(opts, r) { if(r.docs) { LocalDB.sync(r.docs); } + + wn.last_response = r; } wn.request.call = function(opts) { diff --git a/js/wn/views/grid_report.js b/js/wn/views/grid_report.js index 9640b02583..b1c9d5bd07 100644 --- a/js/wn/views/grid_report.js +++ b/js/wn/views/grid_report.js @@ -404,7 +404,7 @@ wn.views.GridReport = Class.extend({ editable: false, enableColumnReorder: false }, - dataview_filter: function(item) { + apply_filters: function(item) { // generic filter: apply filter functiions // from all filter_inputs var filters = this.filter_inputs; diff --git a/py/webnotes/handler.py b/py/webnotes/handler.py index 923ae92e12..e069ecdcc7 100755 --- a/py/webnotes/handler.py +++ b/py/webnotes/handler.py @@ -363,7 +363,8 @@ def print_zip(response): response = compressBuf(response) eprint("Content-Encoding: gzip") eprint("Original-Length: %d" % orig_len) - eprint("Content-Length: %d" % len(response)) + + eprint("Content-Length: %d" % len(response)) eprint("") print response @@ -375,6 +376,8 @@ def json_handler(obj): # serialize date if isinstance(obj, datetime.date): return unicode(obj) + if isinstance(obj, datetime.timedelta): + return unicode(obj) else: raise TypeError, """Object of type %s with value of %s is not JSON serializable""" % \ (type(obj), repr(obj)) diff --git a/py/webnotes/widgets/report_dump.py b/py/webnotes/widgets/report_dump.py index 578c42abef..dc1f2b251b 100644 --- a/py/webnotes/widgets/report_dump.py +++ b/py/webnotes/widgets/report_dump.py @@ -28,20 +28,26 @@ import json def get_data(): from startup.report_data_map import data_map from webnotes.utils import cstr - + import datetime doctypes = json.loads(webnotes.form_dict.get("doctypes")) out = {} + + start = datetime.datetime.now() for d in doctypes: args = data_map[d] conditions = order_by = "" + if args.get("force_index"): + conditions = " force index (%s) " % args["force_index"] if args.get("conditions"): - conditions = " where " + " and ".join(args["conditions"]) + conditions += " where " + " and ".join(args["conditions"]) if args.get("order_by"): order_by = " order by " + args["order_by"] out[d] = {} - out[d]["data"] = webnotes.conn.sql("""select %s from `tab%s` %s %s""" % (",".join(args["columns"]), - d, conditions, order_by), as_list=1) + start = datetime.datetime.now() + out[d]["data"] = [list(t) for t in webnotes.conn.sql("""select %s from `tab%s` %s %s""" % (",".join(args["columns"]), + d, conditions, order_by), debug=True)] + out[d]["time"] = str(datetime.datetime.now() - start) out[d]["columns"] = map(lambda c: c.split(" as ")[-1], args["columns"]) if args.get("links"): @@ -66,8 +72,5 @@ def get_data(): col_idx = out[d]["columns"].index(link_key) # replace by id row[col_idx] = link_map[row[col_idx]] - - #for d in out: - # out[d]["data"] = "~".join(["|".join([cstr(e) for e in p]) for p in out[d]["data"]]) - + return out