From 2ead90fc6e234d9347e9fab625fafa087da1bf1b Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Fri, 27 Jun 2014 20:59:00 +0530 Subject: [PATCH] Misc fixes --- frappe/exceptions.py | 1 + frappe/model/mapper.py | 2 +- frappe/public/js/legacy/datatype.js | 2 ++ frappe/utils/email_lib/bulk.py | 2 +- frappe/utils/email_lib/email_body.py | 7 ++++--- 5 files changed, 9 insertions(+), 5 deletions(-) diff --git a/frappe/exceptions.py b/frappe/exceptions.py index 805d68315b..fbd3fc03be 100644 --- a/frappe/exceptions.py +++ b/frappe/exceptions.py @@ -44,3 +44,4 @@ class DocstatusTransitionError(ValidationError): pass class TimestampMismatchError(ValidationError): pass class EmptyTableError(ValidationError): pass class LinkExistsError(ValidationError): pass +class InvalidEmailAddressError(ValidationError): pass diff --git a/frappe/model/mapper.py b/frappe/model/mapper.py index cdf65cad0a..485a0c0c23 100644 --- a/frappe/model/mapper.py +++ b/frappe/model/mapper.py @@ -22,7 +22,7 @@ def get_mapped_doc(from_doctype, from_docname, table_maps, target_doc=None, elif isinstance(target_doc, basestring): target_doc = frappe.get_doc(json.loads(target_doc)) - if not target_doc.has_permission("create"): + if not ignore_permissions and not target_doc.has_permission("create"): target_doc.raise_no_permission_to("create") map_doc(source_doc, target_doc, table_maps[source_doc.doctype]) diff --git a/frappe/public/js/legacy/datatype.js b/frappe/public/js/legacy/datatype.js index 8bd282bd4f..ad3383a696 100644 --- a/frappe/public/js/legacy/datatype.js +++ b/frappe/public/js/legacy/datatype.js @@ -6,6 +6,8 @@ frappe.utils.full_name = function(fn, ln) { } function fmt_money(v, format){ + // deprecated! + // for backward compatibility return format_number(v, format); } diff --git a/frappe/utils/email_lib/bulk.py b/frappe/utils/email_lib/bulk.py index d3e59f46f3..0ebd72cdab 100644 --- a/frappe/utils/email_lib/bulk.py +++ b/frappe/utils/email_lib/bulk.py @@ -82,7 +82,7 @@ def add(email, sender, subject, formatted, text_content=None, try: e.message = get_email(email, sender=e.sender, formatted=formatted, subject=subject, text_content=text_content).as_string() - except frappe.ValidationError: + except frappe.InvalidEmailAddressError: # bad email id - don't add to queue return diff --git a/frappe/utils/email_lib/email_body.py b/frappe/utils/email_lib/email_body.py index 0a63fbf285..b226930cc9 100644 --- a/frappe/utils/email_lib/email_body.py +++ b/frappe/utils/email_lib/email_body.py @@ -152,17 +152,18 @@ class EMail: def _validate(email): """validate an email field""" if email and not validate_email_add(email): - throw(_("{0} is not a valid email id").format(email)) + throw(_("{0} is not a valid email id").format(email), frappe.InvalidEmailAddressError) return email if not self.sender: self.sender = frappe.db.get_value('Outgoing Email Settings', None, 'auto_email_id') or frappe.conf.get('auto_email_id') or None if not self.sender: - msgprint(_("Please specify 'Auto Email Id' in Setup > Outgoing Email Settings")) + msg = _("Please specify 'Auto Email Id' in Setup > Outgoing Email Settings") + msgprint(msg) if not "expires_on" in frappe.conf: msgprint(_("Alternatively, you can also specify 'auto_email_id' in site_config.json")) - raise frappe.ValidationError + raise frappe.ValidationError, msg self.sender = _validate(self.sender) self.reply_to = _validate(self.reply_to)