From bdd6ab7c9b5399764adac6a4d0144d7175fc659b Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 18 Jun 2012 11:50:56 +0530 Subject: [PATCH 01/14] reload_doc depricated for doctype --- py/webnotes/modules/__init__.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/py/webnotes/modules/__init__.py b/py/webnotes/modules/__init__.py index f7baa8c491..11a04bcf58 100644 --- a/py/webnotes/modules/__init__.py +++ b/py/webnotes/modules/__init__.py @@ -52,6 +52,7 @@ def get_module_path(module): def reload_doc(module, dt=None, dn=None): """reload single / list of records""" + if type(module) is list: for m in module: reload_single_doc(m[0], m[1], m[2]) @@ -60,6 +61,9 @@ def reload_doc(module, dt=None, dn=None): def reload_single_doc(module, dt, dn, force=False): """Sync a file from txt if modifed, return false if not updated""" + if dt.lower() == 'doctype': + return + import os dt, dn = scrub_dt_dn(dt, dn) From bb83a680f812600571a35d45e20831bdcc16ebd6 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Mon, 18 Jun 2012 11:52:05 +0530 Subject: [PATCH 02/14] make amendable and file list function shifted to on update part of doctype.py --- py/core/doctype/doctype/doctype.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/py/core/doctype/doctype/doctype.py b/py/core/doctype/doctype/doctype.py index 69f2969be8..cf610974e1 100644 --- a/py/core/doctype/doctype/doctype.py +++ b/py/core/doctype/doctype/doctype.py @@ -102,11 +102,11 @@ class DocType: self.scrub_field_names() self.validate_fields() self.set_version() - self.make_amendable() - self.make_file_list() - def on_update(self): + self.make_amendable() + self.make_file_list() + sql = webnotes.conn.sql # make schma changes from webnotes.model.db_schema import updatedb From 99250bb270b5bf0d65fc95decd183a697ab6ec52 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Mon, 18 Jun 2012 11:57:30 +0530 Subject: [PATCH 03/14] DocType: Import From File - deprecated --- py/core/doctype/doctype/doctype.js | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/py/core/doctype/doctype/doctype.js b/py/core/doctype/doctype/doctype.js index 97982e6736..4bfeda6a27 100644 --- a/py/core/doctype/doctype/doctype.js +++ b/py/core/doctype/doctype/doctype.js @@ -47,19 +47,8 @@ cur_frm.cscript.refresh = function(doc, cdt, cdn) { Custom Script \ and Property Setter') } - - - // show button for import - cur_frm.add_custom_button('Import from File', cur_frm.cscript.do_import); } cur_frm.cscript.validate = function(doc, cdt, cdn) { doc.server_code_compiled = null; -} - -cur_frm.cscript.do_import = function(doc, cdt, cdn) { - callback = function(r,rt) { - cur_frm.refresh_doc(); - } - $c_obj([doc], 'import_doctype', '', callback) -} +} \ No newline at end of file From ddb6a943de17cd3d4f2d24d44a04f448ff020088 Mon Sep 17 00:00:00 2001 From: Mitesh Date: Mon, 18 Jun 2012 13:14:21 +0530 Subject: [PATCH 04/14] updating the idx of field within its parent doctype --- py/webnotes/model/doctype.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/py/webnotes/model/doctype.py b/py/webnotes/model/doctype.py index 72d21f40be..bb265f69d6 100644 --- a/py/webnotes/model/doctype.py +++ b/py/webnotes/model/doctype.py @@ -180,7 +180,7 @@ class _DocType: for doc_type in doc_type_list: docfields = self.get_sorted_docfields(doclist, doc_type) docfields = self.sort_docfields(doc_type, docfields, prev_field_dict) - if docfields: self.change_idx(doclist, docfields) + if docfields: self.change_idx(doclist, docfields, doc_type) def get_previous_field_properties(self, property_dict): """ @@ -252,9 +252,9 @@ class _DocType: return docfields - def change_idx(self, doclist, docfields): + def change_idx(self, doclist, docfields, doc_type): for d in doclist: - if d.fieldname and d.fieldname in docfields: + if d.fieldname and d.fieldname in docfields and d.parent == doc_type: d.idx = docfields.index(d.fieldname) + 1 def add_code(self, doc): From 8f9fe74f671741f7588a503acbddc3e9e3251d7c Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Mon, 18 Jun 2012 15:05:15 +0530 Subject: [PATCH 05/14] SetTimeout hack - in link fields if data is typed and not selected from autocomplete, run validations and triggers --- js/legacy/widgets/form/fields.js | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/js/legacy/widgets/form/fields.js b/js/legacy/widgets/form/fields.js index 110525c08e..0d8b5481dd 100644 --- a/js/legacy/widgets/form/fields.js +++ b/js/legacy/widgets/form/fields.js @@ -642,13 +642,25 @@ LinkField.prototype.make_input = function() { .appendTo(ul); }; - $(this.txt).change(function() { - if(!$(this).val()) { + $(me.txt).change(function(event) { + //console.log(event); + + me.wait = false; + + var val = me.get_value(); + if(!val) { if(selector && selector.display) return; - me.set_input_value(''); + me.set_input_value(''); } - }) + + // SetTimeout hack! if in put is set via autocomplete, do not validate twice + setTimeout(function() { + if(!me.wait) { + me.validate_link(val); + } + }, 100); + }); } LinkField.prototype.get_custom_query = function() { @@ -701,6 +713,10 @@ LinkField.prototype.setup_buttons = function() { LinkField.prototype.set_input_value = function(val) { var me = this; + + // SetTimeout hack! if in put is set via autocomplete, do not validate twice + me.wait = true; + var from_selector = false; if(selector && selector.display) from_selector = true; @@ -734,7 +750,13 @@ LinkField.prototype.set_input_value = function(val) { me.run_trigger(); return; } + + me.validate_link(val); +} +LinkField.prototype.validate_link = function(val) { + //console.log(['in validate of link field', val]); + var me = this; // validate the value just entered var fetch = ''; if(cur_frm.fetch_dict[me.df.fieldname]) From 21d7a7f293d767cd5e4d4ff36387c465f143b5cd Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Mon, 18 Jun 2012 16:15:29 +0530 Subject: [PATCH 06/14] removed check of is apache user --- py/webnotes/__init__.py | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/py/webnotes/__init__.py b/py/webnotes/__init__.py index 822e9e3fef..14686b9381 100644 --- a/py/webnotes/__init__.py +++ b/py/webnotes/__init__.py @@ -97,14 +97,6 @@ def msgprint(msg, small=0, raise_exception=0, as_table=False): if raise_exception: raise ValidationError, msg -def is_apache_user(): - import os - if os.environ.get('USER') == 'apache': - return True - else: - return (not os.environ.get('USER')) - # os.environ does not have user, so allows a security vulnerability,fixed now. - def get_index_path(): import os return os.sep.join(os.path.dirname(os.path.abspath(__file__)).split(os.sep)[:-2]) @@ -153,9 +145,6 @@ def connect(db_name=None, password=None): """ Connect to this db (or db), if called from command prompt """ - if is_apache_user(): - raise Exception, 'Not for web users!' - import webnotes.db global conn conn = webnotes.db.Database(user=db_name, password=password) From 0bef23f8aa4d63ae3b41d335dbbb010c005cb9be Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Mon, 18 Jun 2012 18:05:00 +0530 Subject: [PATCH 07/14] on cur_frm.clear_custom_buttons call refresh_toolbar of form header --- js/legacy/widgets/form/form.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/legacy/widgets/form/form.js b/js/legacy/widgets/form/form.js index 7214a1a362..18b118fcb8 100644 --- a/js/legacy/widgets/form/form.js +++ b/js/legacy/widgets/form/form.js @@ -369,7 +369,7 @@ _f.Frm.prototype.add_custom_button = function(label, fn, icon) { this.frm_head.appframe.add_button(label, fn, icon); } _f.Frm.prototype.clear_custom_buttons = function() { - // + this.frm_head.refresh_toolbar() } // -------------------------------------------------------------------------------------- From 11826ee98744bcdef77c35bed208e7149108a32e Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 19 Jun 2012 10:30:21 +0530 Subject: [PATCH 08/14] reset to prev version --- js/legacy/widgets/form/fields.js | 30 ++++-------------------------- 1 file changed, 4 insertions(+), 26 deletions(-) diff --git a/js/legacy/widgets/form/fields.js b/js/legacy/widgets/form/fields.js index 0d8b5481dd..110525c08e 100644 --- a/js/legacy/widgets/form/fields.js +++ b/js/legacy/widgets/form/fields.js @@ -642,25 +642,13 @@ LinkField.prototype.make_input = function() { .appendTo(ul); }; - $(me.txt).change(function(event) { - //console.log(event); - - me.wait = false; - - var val = me.get_value(); - if(!val) { + $(this.txt).change(function() { + if(!$(this).val()) { if(selector && selector.display) return; - me.set_input_value(''); + me.set_input_value(''); } - - // SetTimeout hack! if in put is set via autocomplete, do not validate twice - setTimeout(function() { - if(!me.wait) { - me.validate_link(val); - } - }, 100); - }); + }) } LinkField.prototype.get_custom_query = function() { @@ -713,10 +701,6 @@ LinkField.prototype.setup_buttons = function() { LinkField.prototype.set_input_value = function(val) { var me = this; - - // SetTimeout hack! if in put is set via autocomplete, do not validate twice - me.wait = true; - var from_selector = false; if(selector && selector.display) from_selector = true; @@ -750,13 +734,7 @@ LinkField.prototype.set_input_value = function(val) { me.run_trigger(); return; } - - me.validate_link(val); -} -LinkField.prototype.validate_link = function(val) { - //console.log(['in validate of link field', val]); - var me = this; // validate the value just entered var fetch = ''; if(cur_frm.fetch_dict[me.df.fieldname]) From 6151eff8cb1b93c9e32ff929f9646d77facca3b1 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Tue, 19 Jun 2012 17:52:32 +0530 Subject: [PATCH 09/14] add parent column in filter list --- js/core.min.js | 3 ++- js/wn/ui/filters.js | 25 +++++++++++++++++++++---- js/wn/views/reportview.js | 2 +- 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/js/core.min.js b/js/core.min.js index 12520f68e2..5d7b6f7cc1 100644 --- a/js/core.min.js +++ b/js/core.min.js @@ -228,7 +228,8 @@ df.original_type=df.fieldtype;df.description='';df.reqd=0;if(fieldtype){df.field if(df.fieldtype=='Check'){df.fieldtype='Select';df.options='No\nYes';}else if(['Text','Text Editor','Code','Link'].indexOf(df.fieldtype)!=-1){df.fieldtype='Data';}},set_default_condition:function(df,fieldtype){if(!fieldtype){if(df.fieldtype=='Data'){this.$w.find('.condition').val('like');}else{this.$w.find('.condition').val('=');}}},get_value:function(){var me=this;var val=me.field.get_value();var cond=me.$w.find('.condition').val();if(me.field.df.original_type=='Check'){val=(val=='Yes'?1:0);} if(cond=='like'){val=val+'%';} return[me.fieldselect.$select.find('option:selected').attr('table'),me.field.df.fieldname,me.$w.find('.condition').val(),cstr(val)];}});wn.ui.FieldSelect=Class.extend({init:function(parent,doctype,filter_fields,with_blank){this.doctype=doctype;this.fields_by_name={};this.with_blank=with_blank;this.$select=$('