From 446024b9f555ed58faf5c292b2a2fd4e1be1beaa Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Tue, 8 May 2012 12:17:36 +0530 Subject: [PATCH 1/2] fix in form email --- js/legacy/widgets/form/email.js | 8 +- .../doctype/doctype_mapper/doctype_mapper.py | 98 +++++++++++-------- py/webnotes/__init__.py | 4 +- wnf.py | 7 +- 4 files changed, 70 insertions(+), 47 deletions(-) diff --git a/js/legacy/widgets/form/email.js b/js/legacy/widgets/form/email.js index d7be5ea68b..7947c30c0e 100644 --- a/js/legacy/widgets/form/email.js +++ b/js/legacy/widgets/form/email.js @@ -61,15 +61,19 @@ _e.make = function() { if(!emailfrom) emailfrom = user_email; + emailto = emailto.replace(/ /g, ""); // validate email ids var email_list = emailto.split(/[,|;]/); var valid = 1; for(var i=0;i=':'greater than equal to ', '>':'greater than ', '<=':'less than equal to ', '<':'less than '} - msgprint(to_label + " should be " + op_in_words[operator] + from_label + " of " + self.doc.from_doctype + ": " + self.ref_doc, raise_exception=1) + msgprint("%s should be %s %s of %s: %s" % (to_label, op_in_words[operator], from_label, self.doc.from_doctype, self.ref_doc), raise_exception=1) + 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)) if not det: - msgprint(self.doc.from_doctype + ": " + self.ref_doc + " does not exists in the system", raise_exception=1) + 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: - msgprint(self.doc.from_doctype + ": " + self.ref_doc + " is not Submitted Document.", raise_exception=1) + msgprint("%s: %s is not submitted document." % (self.doc.from_doctype, self.ref_doc), raise_exception=1) + def on_update(self): """ diff --git a/py/webnotes/__init__.py b/py/webnotes/__init__.py index 1e35ab6870..c1d6f20b7c 100644 --- a/py/webnotes/__init__.py +++ b/py/webnotes/__init__.py @@ -149,7 +149,7 @@ def remove_file(path): if e.args[0]!=2: raise e -def connect(db_name=None): +def connect(db_name=None, password=None): """ Connect to this db (or db), if called from command prompt """ @@ -158,7 +158,7 @@ def connect(db_name=None): import webnotes.db global conn - conn = webnotes.db.Database(user=db_name) + conn = webnotes.db.Database(user=db_name, password=password) global session session = {'user':'Administrator'} diff --git a/wnf.py b/wnf.py index 131875b1f5..190831f656 100755 --- a/wnf.py +++ b/wnf.py @@ -78,6 +78,8 @@ def setup_options(): parser.add_option("-d", "--db", dest="db_name", help="Apply the patches on given db") + parser.add_option("--password", + help="Password for given db", nargs=1) # build parser.add_option("-b", "--build", default=False, action="store_true", @@ -158,7 +160,10 @@ def run(): # connect if options.db_name is not None: - webnotes.connect(options.db_name) + if options.password: + webnotes.connect(options.db_name, options.password) + else: + webnotes.connect(options.db_name) elif not options.install: webnotes.connect(conf.db_name) From 220bee1c87a7a35d054da76332735c16d6dc80f6 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Tue, 8 May 2012 18:01:45 +0530 Subject: [PATCH 2/2] fix in get_link_fields function of meta --- py/webnotes/model/meta.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/py/webnotes/model/meta.py b/py/webnotes/model/meta.py index f35a77d7e5..4ab82ab3f7 100644 --- a/py/webnotes/model/meta.py +++ b/py/webnotes/model/meta.py @@ -57,12 +57,18 @@ def get_link_fields(doctype): """ Returns list of link fields for a doctype in tuple (fieldname, options, label) """ - return webnotes.conn.sql(""" - SELECT fieldname, options, label - FROM tabDocField - WHERE parent='%s' - and (fieldtype='Link' or (fieldtype='Select' and `options` like 'link:%%')) - and fieldname!='owner'""" % (doctype)) + import webnotes.model.doctype + doclist = webnotes.model.doctype.get(doctype) + return [ + (d.fields.get('fieldname'), d.fields.get('options'), d.fields.get('label')) + for d in doclist + if d.fields.get('doctype') == 'DocField' and d.fields.get('parent') == doctype + and d.fields.get('fieldname')!='owner' + and (d.fields.get('fieldtype') == 'Link' or + ( d.fields.get('fieldtype') == 'Select' + and (d.fields.get('options') or '').startswith('link:')) + ) + ] #=================================================================================