From 94de362e3cb720a23ed60b6db81e0b02adfd0926 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Wed, 9 Sep 2015 14:04:41 +0530 Subject: [PATCH] [minor] frappe.are_emails_muted --- frappe/__init__.py | 3 +++ frappe/email/bulk.py | 2 +- frappe/email/smtp.py | 4 ++-- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/frappe/__init__.py b/frappe/__init__.py index 3a4a09ce42..ea7432f562 100644 --- a/frappe/__init__.py +++ b/frappe/__init__.py @@ -919,6 +919,9 @@ def as_json(obj, indent=1): from frappe.utils.response import json_handler return json.dumps(obj, indent=indent, sort_keys=True, default=json_handler) +def are_emails_muted(): + return flags.mute_emails or conf.get("mute_emails") or False + def get_test_records(doctype): """Returns list of objects from `test_records.json` in the given doctype's folder.""" from frappe.modules import get_doctype_module, get_module_path diff --git a/frappe/email/bulk.py b/frappe/email/bulk.py index c5ed6e7ca3..3d958fb51f 100644 --- a/frappe/email/bulk.py +++ b/frappe/email/bulk.py @@ -190,7 +190,7 @@ def flush(from_test=False): # additional check check_bulk_limit([]) - if frappe.flags.mute_emails or frappe.conf.get("mute_emails") or False: + if frappe.are_emails_muted(): msgprint(_("Emails are muted")) from_test = True diff --git a/frappe/email/smtp.py b/frappe/email/smtp.py index 714d64423d..c24ea82807 100644 --- a/frappe/email/smtp.py +++ b/frappe/email/smtp.py @@ -15,7 +15,7 @@ def send(email, append_to=None): frappe.flags.sent_mail = email.as_string() return - if frappe.flags.mute_emails or frappe.conf.get("mute_emails") or False: + if frappe.are_emails_muted(): frappe.msgprint(_("Emails are muted")) return @@ -81,7 +81,7 @@ def get_default_outgoing_email_account(raise_exception_not_set=True): if not email_account and not raise_exception_not_set: return None - if frappe.flags.mute_emails or frappe.conf.get("mute_emails") or False: + if frappe.are_emails_muted(): # create a stub email_account = frappe.new_doc("Email Account") email_account.update({