fix: move email status check to fix travis

mail status wasn't being set when the check was run, so the output for
any() would always be false, and none of the mails would have status set
to sent in the backend. moving the check to a point after setting status
for each email should fix this issue

Signed-off-by: Chinmay D. Pai <chinmaydpai@gmail.com>
This commit is contained in:
Chinmay D. Pai 2020-01-01 11:21:53 +05:30
parent e2935b5ba6
commit 4c138390b6
No known key found for this signature in database
GPG key ID: 75507BE256F40CED

View file

@ -382,8 +382,6 @@ def send_one(email, smtpserver=None, auto_commit=True, now=False, from_test=Fals
recipients_list = frappe.db.sql('''select name, recipient, status from
`tabEmail Queue Recipient` where parent=%s''', email.name, as_dict=1)
email_sent_to_any_recipient = any("Sent" == s.status for s in recipients_list)
if frappe.are_emails_muted():
frappe.msgprint(_("Emails are muted"))
return
@ -427,6 +425,8 @@ def send_one(email, smtpserver=None, auto_commit=True, now=False, from_test=Fals
frappe.db.sql("""update `tabEmail Queue Recipient` set status='Sent', modified=%s where name=%s""",
(now_datetime(), recipient.name), auto_commit=auto_commit)
email_sent_to_any_recipient = any("Sent" == s.status for s in recipients_list)
#if all are sent set status
if email_sent_to_any_recipient:
frappe.db.sql("""update `tabEmail Queue` set status='Sent', modified=%s where name=%s""",