Misc fixes

This commit is contained in:
Anand Doshi 2014-06-27 20:59:00 +05:30
parent eb2f51307e
commit 2ead90fc6e
5 changed files with 9 additions and 5 deletions

View file

@ -44,3 +44,4 @@ class DocstatusTransitionError(ValidationError): pass
class TimestampMismatchError(ValidationError): pass
class EmptyTableError(ValidationError): pass
class LinkExistsError(ValidationError): pass
class InvalidEmailAddressError(ValidationError): pass

View file

@ -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])

View file

@ -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);
}

View file

@ -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

View file

@ -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)