Added email vaildation

This commit is contained in:
Nile Walker 2021-02-04 09:11:19 -05:00
parent 5baca8fa3f
commit 5a64a1d205
2 changed files with 6 additions and 0 deletions

View File

@ -193,10 +193,14 @@ def _notify_by_email(file_name=None, retry=False):
if last_failure and not retry:
continue
try:
assert (sample.email != None)
notifier.send_result_email(sample)
count += 1
sample.email_notified = True
db.session.add(Notification(type=EMAIL_TYPE, sample=sample, successful=True))
except AssertionError as e:
app.logger.error(f'Email not provided for Sample: {sample.barcode} ', exc_info=True)
continue
except smtplib.SMTPServerDisconnected as de:
app.logger.error("Database connection terminated, stopping for now.", exc_info=True)
break

View File

@ -145,6 +145,8 @@ def get_topbar_data(last_modified = None, start_date = None, end_date = None, st
response[4] = notifications.filter(Notification.successful == "f").filter(Notification.type == "email").count()
response[5] = notifications.filter(Notification.successful == "t").filter(Notification.type == "text").count()
response[6] = notifications.filter(Notification.successful == "f").filter(Notification.type == "text").count()
response[7] = 9
return response