[fix] add subscribers even though some emails are invalid

This commit is contained in:
makeen 2016-02-15 10:44:11 +01:00
parent 6921894f8e
commit 4741182b25

View File

@ -67,9 +67,9 @@ def add_subscribers(name, email_list):
count = 0 count = 0
for email in email_list: for email in email_list:
email = email.strip() email = email.strip()
validate_email_add(email, True) valid = validate_email_add(email, False)
if email: if valid:
if not frappe.db.get_value("Newsletter List Subscriber", if not frappe.db.get_value("Newsletter List Subscriber",
{"newsletter_list": name, "email": email}): {"newsletter_list": name, "email": email}):
frappe.get_doc({ frappe.get_doc({
@ -81,6 +81,8 @@ def add_subscribers(name, email_list):
count += 1 count += 1
else: else:
pass pass
else:
frappe.msgprint(_("{0} is not a valid email id").format(email))
frappe.msgprint(_("{0} subscribers added").format(count)) frappe.msgprint(_("{0} subscribers added").format(count))