diff --git a/erpnext/hr/doctype/attendance_control_panel/attendance_control_panel.py b/erpnext/hr/doctype/attendance_control_panel/attendance_control_panel.py index 6225b352538..d845d10275a 100644 --- a/erpnext/hr/doctype/attendance_control_panel/attendance_control_panel.py +++ b/erpnext/hr/doctype/attendance_control_panel/attendance_control_panel.py @@ -49,7 +49,7 @@ class DocType: res = sql("select name, employee_name from `tabEmployee` where status = 'Active' and docstatus !=2") for d in dt: - for r in res: + for r in res: lst.append([r[0],r[1],d,'',fy,comp,sr]) return lst @@ -69,7 +69,7 @@ class DocType: else: r = 1 dateList = [getdate(self.doc.att_fr_date)+datetime.timedelta(days=i) for i in range(0,r)] - dt=([str(date) for date in dateList]) + dt=([formatdate(cstr(date)) for date in dateList]) return dt diff --git a/erpnext/setup/doctype/price_list/price_list.py b/erpnext/setup/doctype/price_list/price_list.py index ad144acf092..02f6b89e5f1 100644 --- a/erpnext/setup/doctype/price_list/price_list.py +++ b/erpnext/setup/doctype/price_list/price_list.py @@ -52,8 +52,9 @@ class DocType: # update prices in Price List def update_prices(self): - import csv - data = csv.reader(self.get_csv_data().splitlines()) + from core.page.data_import_tool.data_import_tool import read_csv_content + + data = read_csv_content(self.get_csv_data()) updated = 0 @@ -98,9 +99,5 @@ class DocType: except Exception, e: webnotes.msgprint("Unable to open attached file. Please try again.") raise e - - # NOTE: Don't know why this condition exists - if not isinstance(content, basestring) and hasattr(content, 'tostring'): - content = content.tostring() return content diff --git a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py index 7dd121f43ce..9a901afb70a 100644 --- a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py +++ b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py @@ -47,10 +47,6 @@ class DocType: from webnotes.utils import file_manager fn, content = file_manager.get_file(filename[1]) - - # NOTE: Don't know why this condition exists - if not isinstance(content, basestring) and hasattr(content, 'tostring'): - content = content.tostring() else: content = self.doc.diff_info @@ -82,8 +78,11 @@ class DocType: def get_reconciliation_data(self,submit = 1): """Read and validate csv data""" - import csv - data = csv.reader(self.get_csv_file_data(submit).splitlines()) + import csv + from webnotes.utils import get_encoded_string + from core.page.data_import_tool.data_import_tool import read_csv_content + csv_content = get_encoded_string(self.get_csv_file_data(submit)) + data = read_csv_content(csv_content) self.convert_into_list(data, submit) @@ -186,7 +185,7 @@ class DocType: # Diff between file and system qty_diff = row[2] != '~' and flt(row[2]) - flt(sys_stock['actual_qty']) or 0 rate_diff = row[3] != '~' and flt(row[3]) - flt(sys_stock['val_rate']) or 0 - + # Make sl entry if qty_diff: self.make_sl_entry(is_submit, row, qty_diff, sys_stock) diff --git a/public/server.py b/public/server.py index 497346c9597..b95ac20a57b 100755 --- a/public/server.py +++ b/public/server.py @@ -42,10 +42,7 @@ import webnotes.auth from webnotes.utils import cstr def init(): - # make the form_dict - webnotes.form = cgi.FieldStorage(keep_blank_values=True) - for key in webnotes.form.keys(): - webnotes.form_dict[key] = cstr(webnotes.form.getvalue(key)) + webnotes.handler.get_cgi_fields() # init request try: diff --git a/public/web.py b/public/web.py index 4696ebe0423..ff52e7db5af 100755 --- a/public/web.py +++ b/public/web.py @@ -16,13 +16,12 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . +""" + return a dynamic page from website templates + + all html pages related to website are generated here +""" from __future__ import unicode_literals -""" -return a dynamic page from website templates - -all html pages except login-page.html get generated here -""" - import cgi, cgitb, os, sys cgitb.enable() @@ -33,10 +32,8 @@ sys.path.append('../lib/py') sys.path.append(conf.modules_path) def init(): - import webnotes - webnotes.form = cgi.FieldStorage(keep_blank_values=True) - for key in webnotes.form.keys(): - webnotes.form_dict[key] = webnotes.form.getvalue(key) + import webnotes.handler + webnotes.handler.get_cgi_fields() webnotes.connect() def respond(): @@ -50,10 +47,19 @@ def respond(): html = get_html('index') except Exception, e: html = get_html('404') - - print "Content-Type: text/html" - print - print get_encoded_string(html) + + content = [] + import webnotes.handler + html = get_encoded_string(html) + html, content = webnotes.handler.gzip_response(html, content) + + content += [ + "Content-Type: text/html", + "", + ] + + webnotes.handler.print_content(content) + print html def get_html(page_name): import website.utils