From 8a0fc9e4509592b860a6a142f3b62d567412f7c3 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Wed, 30 May 2012 17:41:32 +0530 Subject: [PATCH 01/11] added option to ignore encoding errors --- .../page/data_import_tool/data_import_tool.js | 5 +++++ .../page/data_import_tool/data_import_tool.py | 17 ++++++++++------- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/py/core/page/data_import_tool/data_import_tool.js b/py/core/page/data_import_tool/data_import_tool.js index 61800d04c2..83231591a5 100644 --- a/py/core/page/data_import_tool/data_import_tool.js +++ b/py/core/page/data_import_tool/data_import_tool.js @@ -121,6 +121,11 @@ wn.pages['data-import-tool'].onload = function(wrapper) { $(' Overwrite

') .insertBefore('#dit-upload-area form input[type="submit"]') + // add ignore option + $(' Ignore Encoding Errors

') + .insertBefore('#dit-upload-area form input[type="submit"]') + + // add overwrite option $('Date Format:

') .insertBefore('#dit-upload-area form input[type="submit"]') diff --git a/py/core/page/data_import_tool/data_import_tool.py b/py/core/page/data_import_tool/data_import_tool.py index d0d5d0fad1..6063b600f8 100644 --- a/py/core/page/data_import_tool/data_import_tool.py +++ b/py/core/page/data_import_tool/data_import_tool.py @@ -132,13 +132,16 @@ def upload(): for row in csvrows: newrow = [] for val in row: - try: - newrow.append(unicode(val.strip(), 'utf-8')) - except UnicodeDecodeError, e: - raise Exception, """Some character(s) in row #%s, column #%s are - not readable by utf-8. Ignoring them. If you are importing a non - english language, please make sure your file is saved in the 'utf-8' - encoding.""" % (csvrows.index(row)+1, row.index(val)+1) + if webnotes.form_dict.get('ignore_encoding_errors'): + newrow.append(unicode(val.strip(), 'utf-8', errors='ignore')) + else: + try: + newrow.append(unicode(val.strip(), 'utf-8')) + except UnicodeDecodeError, e: + raise Exception, """Some character(s) in row #%s, column #%s are + not readable by utf-8. Ignoring them. If you are importing a non + english language, please make sure your file is saved in the 'utf-8' + encoding.""" % (csvrows.index(row)+1, row.index(val)+1) rows.append(newrow) From 6f7d06f19a16e928d0751a19e26cceba165ab83e Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Mon, 4 Jun 2012 11:22:43 +0530 Subject: [PATCH 02/11] seperate custome client script by a line break during concatenation, in doctype.py --- py/webnotes/model/doctype.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/py/webnotes/model/doctype.py b/py/webnotes/model/doctype.py index e653340f5f..72d21f40be 100644 --- a/py/webnotes/model/doctype.py +++ b/py/webnotes/model/doctype.py @@ -295,7 +295,7 @@ class _DocType: # custom script from webnotes.model.code import get_custom_script custom = get_custom_script(doc.name, 'Client') or '' - doc.fields['__js'] = doc.fields.setdefault('__js', '') + custom + doc.fields['__js'] = doc.fields.setdefault('__js', '') + '\n' + custom def load_select_options(self, doclist): From 331af9a5d8990e373881f4c5627be774cec083b4 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Mon, 4 Jun 2012 12:39:29 +0530 Subject: [PATCH 03/11] fix in get_fields_with_same_name of doctype_mapper --- py/core/doctype/doctype_mapper/doctype_mapper.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/py/core/doctype/doctype_mapper/doctype_mapper.py b/py/core/doctype/doctype_mapper/doctype_mapper.py index acca86f58f..befb7adec4 100644 --- a/py/core/doctype/doctype_mapper/doctype_mapper.py +++ b/py/core/doctype/doctype_mapper/doctype_mapper.py @@ -142,11 +142,11 @@ class DocType: exception_flds = copy.copy(default_fields) exception_flds += [f[1] for f in flds] - from_flds = [d.fieldname for d in get(t['from_table']) \ + from_flds = [d.fieldname for d in get(t['from_table'], 0) \ if cint(d.no_copy) == 0 and d.docstatus != 2 and d.fieldname \ and d.fieldtype not in ('Table', 'Section Break', 'Column Break', 'HTML')] - to_flds = [d.fieldname for d in get(t['to_table']) \ + to_flds = [d.fieldname for d in get(t['to_table'], 0) \ if cint(d.no_copy) == 0 and d.docstatus != 2 and d.fieldname \ and d.fieldtype not in ('Table', 'Section Break', 'Column Break', 'HTML')] From 4a2596e87274ad27bbb70e176fdcbe18461bd8b0 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Mon, 4 Jun 2012 12:57:34 +0530 Subject: [PATCH 04/11] update in Task, notification and layout --- py/core/doctype/letter_head/letter_head.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/py/core/doctype/letter_head/letter_head.js b/py/core/doctype/letter_head/letter_head.js index f1f8e62d8a..acf93002df 100644 --- a/py/core/doctype/letter_head/letter_head.js +++ b/py/core/doctype/letter_head/letter_head.js @@ -34,7 +34,7 @@ cur_frm.cscript['set_from_image'] = function(doc, dt, dn) { return; } - var file_name = doc.file_list.split(',')[0] + var file_name = doc.file_list.split(',')[1] if(!in_list(['gif','jpg','jpeg','png'], file_name.split('.')[1].toLowerCase())) { msgprint("Please upload a web friendly (GIF, JPG or PNG) image file for the letter head"); From 0631708cd04df3163b6d22385d35125e0cd8e748 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Mon, 4 Jun 2012 13:06:31 +0530 Subject: [PATCH 05/11] fix in get_base_url of dom.js --- js/legacy/utils/dom.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/legacy/utils/dom.js b/js/legacy/utils/dom.js index dbc1767c6f..5e38849116 100644 --- a/js/legacy/utils/dom.js +++ b/js/legacy/utils/dom.js @@ -374,7 +374,7 @@ wn.urllib = { // returns the base url with http + domain + path (-index.cgi or # or ?) get_base_url: function() { - var url= window.location.href.split('#')[0].split('?')[0].split('index.cgi')[0]; + var url= window.location.href.split('#')[0].split('?')[0].split('app.html')[0]; if(url.substr(url.length-1, 1)=='/') url = url.substr(0, url.length-1) return url }, From 2870a97720d3d384841dec8d3edf11c005b96f1d Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Mon, 4 Jun 2012 13:21:40 +0530 Subject: [PATCH 06/11] gantt chart fixes --- js/legacy/utils/datetime.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/js/legacy/utils/datetime.js b/js/legacy/utils/datetime.js index 42333bd97c..65238fd366 100644 --- a/js/legacy/utils/datetime.js +++ b/js/legacy/utils/datetime.js @@ -41,6 +41,7 @@ function int_to_str(i, len) { wn.datetime = { str_to_obj: function(d) { + if(typeof d=="object") return d; if(!d) return new Date(); var tm = [null, null]; if(d.search(' ')!=-1) { @@ -57,6 +58,7 @@ wn.datetime = { }, obj_to_str: function(d) { + if(typeof d=='string') return d; return d.getFullYear() + '-' + int_to_str(d.getMonth()+1,2) + '-' + int_to_str(d.getDate(),2); }, @@ -76,9 +78,9 @@ wn.datetime = { }, add_days: function(d, days) { - dt = dateutil.str_to_obj(d) - dt.setTime(dt.getTime()+(days*24*60*60*1000)); - return dateutil.obj_to_str(dt); + var dt = dateutil.str_to_obj(d); + var new_dt = new Date(dt.getTime()+(days*24*60*60*1000)); + return dateutil.obj_to_str(new_dt); }, add_months: function(d, months) { From 221ab4273ba0e85808a2e88e691bcfc9d6276d2e Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Tue, 5 Jun 2012 09:20:41 +0530 Subject: [PATCH 07/11] cms page creation moved to a function --- wnf.py | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/wnf.py b/wnf.py index 5f4f69b395..41c4feaf8a 100755 --- a/wnf.py +++ b/wnf.py @@ -70,6 +70,23 @@ def search_replace_with_prompt(fpath, txt1, txt2): f.write(''.join(tmp)) print colored('Updated', 'green') +def create_cms_files(): + from webnotes.model.code import get_obj + + # rewrite pages + ws = get_obj('Website Settings') + ws.rewrite_pages() + ss = get_obj('Style Settings') + ss.validate() + ss.doc.save() + ss.on_update() + + # create login-page.html if it doesnt exist by copying index.html + if not os.path.exists('public/login-page.html') and os.path.exists('public/index.html'): + os.system('cp public/index.html public/login-page.html') + + # change owner of files + os.system('chown -R apache:apache *') def setup_options(): from optparse import OptionParser @@ -173,22 +190,7 @@ def run(): build.project.build() elif options.cms: - from webnotes.model.code import get_obj - - # rewrite pages - ws = get_obj('Website Settings') - ws.rewrite_pages() - ss = get_obj('Style Settings') - ss.validate() - ss.doc.save() - ss.on_update() - - # create login-page.html if it doesnt exist by copying index.html - if not os.path.exists('public/login-page.html') and os.path.exists('public/index.html'): - os.system('cp public/index.html public/login-page.html') - - # change owner of files - os.system('chown -R apache:apache *') + create_cms_files() # code replace elif options.replace: From 78e5ed1b440c473c4451f1eeb334b1f160822930 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Tue, 5 Jun 2012 12:04:55 +0530 Subject: [PATCH 08/11] fix in doctype mapper where doctype.get function is used --- py/core/doctype/doctype_mapper/doctype_mapper.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/py/core/doctype/doctype_mapper/doctype_mapper.py b/py/core/doctype/doctype_mapper/doctype_mapper.py index befb7adec4..c1caaa17bd 100644 --- a/py/core/doctype/doctype_mapper/doctype_mapper.py +++ b/py/core/doctype/doctype_mapper/doctype_mapper.py @@ -200,8 +200,8 @@ class DocType: """ flds = {} for t in getlist(self.doclist, 'table_mapper_details'): - from_flds = [cstr(d.fieldname) for d in get(t.from_table)] - to_flds = [cstr(d.fieldname) for d in get(t.to_table)] + from_flds = [cstr(d.fieldname) for d in get(t.from_table, 0)] + to_flds = [cstr(d.fieldname) for d in get(t.to_table, 0)] flds[cstr(t.match_id)] = [cstr(t.from_table), from_flds, cstr(t.to_table), to_flds] for d in getlist(self.doclist, 'field_mapper_details'): @@ -235,10 +235,10 @@ class DocType: def get_label_and_type(self, from_dt, to_dt): """get label, fieldtype""" from_flds, to_flds = {}, {} - for d in get(from_dt): + for d in get(from_dt, 0): from_flds[d.fieldname] = {'label': d.label, 'fieldtype': d.fieldtype} - for d in get(to_dt): + for d in get(to_dt, 0): to_flds[d.fieldname] = {'label': d.label, 'fieldtype': d.fieldtype} return from_flds, to_flds From 5bfa8690d96f8ee1192c50517f5c911470bc7414 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Tue, 5 Jun 2012 13:14:35 +0530 Subject: [PATCH 09/11] fix in sql syntax --- .../doctype/doctype_mapper/doctype_mapper.py | 34 +++++++++++++------ 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/py/core/doctype/doctype_mapper/doctype_mapper.py b/py/core/doctype/doctype_mapper/doctype_mapper.py index c1caaa17bd..9ace244bc2 100644 --- a/py/core/doctype/doctype_mapper/doctype_mapper.py +++ b/py/core/doctype/doctype_mapper/doctype_mapper.py @@ -73,8 +73,10 @@ class DocType: if not doclist: doclist.append(to_doc) - tbl_list = sql("select from_table, to_table, from_field, to_field, match_id, validation_logic \ - from `tabTable Mapper Detail` where parent ='%s' order by match_id" % self.doc.name, as_dict=1) + tbl_list = sql("""\ + select from_table, to_table, from_field, to_field, match_id, validation_logic + from `tabTable Mapper Detail` where parent ="%s"" order by match_id""" \ + % self.doc.name, as_dict=1) for t in tbl_list: if [t['from_table'], t['to_table']] in eval(from_to_list): @@ -114,11 +116,14 @@ class DocType: """ docnames = () if t['from_table'] == self.doc.from_doctype: - docnames = sql("select name from `tab%s` where name = '%s' and %s" % (from_dt, from_dn, t['validation_logic'])) + docnames = sql("""select name from `tab%s` where name = "%s" and %s""" \ + % (from_dt, from_dn, t['validation_logic'])) if not docnames: msgprint("Validation failed in doctype mapper. Please contact Administrator.", raise_exception=1) else: - docnames = sql("select name from `tab%s` where parent='%s' and parenttype = '%s' and %s order by idx" \ + docnames = sql("""\ + select name from `tab%s` + where parent="%s" and parenttype = "%s" and %s order by idx""" \ % (t['from_table'], from_dn, self.doc.from_doctype, t['validation_logic'])) return docnames @@ -129,7 +134,7 @@ class DocType: return [[f[0], f[1], f[2]] for f in sql(""" select from_field, to_field, map from `tabField Mapper Detail` - where parent = '%s' and match_id = %s + where parent = "%s" and match_id = %s """ % (self.doc.name, t['match_id']))] @@ -262,15 +267,21 @@ class DocType: cur_val = '%.2f' % flt(cur_val) if cl['op'] == '=' and to_flds[cl['to_fld']]['fieldtype'] in ['Currency', 'Float']: - consistent = sql("select name, %s from `tab%s` where name = '%s' and '%s' - %s <= 0.5" \ - % (cl['from_fld'], t.from_table, child_obj.fields[t.reference_key], flt(cur_val), cl['from_fld'])) + consistent = sql("""\ + select name, %s from `tab%s` + where name = "%s" and "%s" - %s <= 0.5""" \ + % (cl['from_fld'], t.from_table, child_obj.fields[t.reference_key], + flt(cur_val), cl['from_fld'])) else: - consistent = sql("select name, %s from `tab%s` where name = '%s' and '%s' %s ifnull(%s, '')" \ + consistent = sql("""\ + select name, %s from `tab%s` + where name = "%s" and "%s" %s ifnull(%s, '')""" \ % (cl['from_fld'], t.from_table, child_obj.fields[t.reference_key], \ - to_flds[cl['to_fld']]['fieldtype'] in ('Currency', 'Float', 'Int') and flt(cur_val) or cstr(cur_val), cl['op'], cl['from_fld'])) + to_flds[cl['to_fld']]['fieldtype'] in ('Currency', 'Float', 'Int') \ + and flt(cur_val) or cstr(cur_val), cl['op'], cl['from_fld'])) if not self.ref_doc: - det = sql("select name, parent from `tab%s` where name = '%s'" % (t.from_table, child_obj.fields[t.reference_key])) + det = sql("""select name, parent from `tab%s` where name = \"%s\"""" % (t.from_table, child_obj.fields[t.reference_key])) self.ref_doc = det[0][1] and det[0][1] or det[0][0] if not consistent: @@ -285,7 +296,8 @@ class DocType: def check_ref_docstatus(self): if self.ref_doc: - det = sql("select name, docstatus from `tab%s` where name = '%s'" % (self.doc.from_doctype, self.ref_doc)) + det = sql("""select name, docstatus from `tab%s` where name = \"%s\"""" \ + % (self.doc.from_doctype, self.ref_doc)) if not det: msgprint("%s: %s does not exists in the system" % (self.doc.from_doctype, self.ref_doc), raise_exception=1) elif self.doc.ref_doc_submitted and det[0][1] != 1: From 1ec77502b08e63017cc45381b8d71cf7545b1d47 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Tue, 5 Jun 2012 13:37:56 +0530 Subject: [PATCH 10/11] fix in syntax error in doctype mapper --- py/core/doctype/doctype_mapper/doctype_mapper.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/py/core/doctype/doctype_mapper/doctype_mapper.py b/py/core/doctype/doctype_mapper/doctype_mapper.py index 9ace244bc2..bcabd6db15 100644 --- a/py/core/doctype/doctype_mapper/doctype_mapper.py +++ b/py/core/doctype/doctype_mapper/doctype_mapper.py @@ -75,7 +75,7 @@ class DocType: tbl_list = sql("""\ select from_table, to_table, from_field, to_field, match_id, validation_logic - from `tabTable Mapper Detail` where parent ="%s"" order by match_id""" \ + from `tabTable Mapper Detail` where parent ="%s" order by match_id""" \ % self.doc.name, as_dict=1) for t in tbl_list: From 8ada5cb2e8d09c98b0be6b86c4717db15c79c862 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Tue, 5 Jun 2012 16:01:09 +0530 Subject: [PATCH 11/11] auto complete works in login page --- py/core/page/login_page/login_page.html | 4 +++- py/core/page/login_page/login_page.js | 10 ++++++++-- wnf.py | 2 +- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/py/core/page/login_page/login_page.html b/py/core/page/login_page/login_page.html index 32790f5d29..eeaa229fd1 100644 --- a/py/core/page/login_page/login_page.html +++ b/py/core/page/login_page/login_page.html @@ -1,6 +1,7 @@
+
@@ -22,11 +23,12 @@
  - +
+

Forgot Password

diff --git a/py/core/page/login_page/login_page.js b/py/core/page/login_page/login_page.js index e52085f75c..e6beb7384e 100644 --- a/py/core/page/login_page/login_page.js +++ b/py/core/page/login_page/login_page.js @@ -31,8 +31,12 @@ pscript['onload_Login Page'] = function(wrapper){ $('#login_btn').click(pscript.doLogin) $('#password').keypress(function(ev){ - if(ev.which==13 && $('#password').val()) - pscript.doLogin(); + if(ev.which==13 && $('#password').val()) { + $('form').submit(function() { + pscript.doLogin(); + return false; + }); + } }); $(document).trigger('login_rendered'); } @@ -65,6 +69,8 @@ pscript.doLogin = function(){ $('#login_btn').set_working(); $c("login", args, pscript.onLoginReply); + + return false; } diff --git a/wnf.py b/wnf.py index 41c4feaf8a..bde9df490e 100755 --- a/wnf.py +++ b/wnf.py @@ -72,7 +72,7 @@ def search_replace_with_prompt(fpath, txt1, txt2): def create_cms_files(): from webnotes.model.code import get_obj - + os.system('rm public/login-page.html') # rewrite pages ws = get_obj('Website Settings') ws.rewrite_pages()