Add `name` to email script and email_service

This commit is contained in:
mike cullerton 2022-04-25 15:38:15 -04:00
parent 56fe0bb606
commit b52343903c
2 changed files with 7 additions and 3 deletions

View File

@ -63,6 +63,7 @@ email(subject="My Subject", recipients="user@example.com", attachments=['Study_A
bcc = [] bcc = []
reply_to = None reply_to = None
files = None files = None
name = None
if 'cc' in kwargs and kwargs['cc'] is not None: if 'cc' in kwargs and kwargs['cc'] is not None:
cc = self.get_email_addresses(kwargs['cc'], study_id) cc = self.get_email_addresses(kwargs['cc'], study_id)
if 'bcc' in kwargs and kwargs['bcc'] is not None: if 'bcc' in kwargs and kwargs['bcc'] is not None:
@ -72,6 +73,8 @@ email(subject="My Subject", recipients="user@example.com", attachments=['Study_A
# Don't process if attachments is None or '' # Don't process if attachments is None or ''
if 'attachments' in kwargs and kwargs['attachments'] is not None and kwargs['attachments'] != '': if 'attachments' in kwargs and kwargs['attachments'] is not None and kwargs['attachments'] != '':
files = self.get_files(kwargs['attachments'], study_id) files = self.get_files(kwargs['attachments'], study_id)
if 'name' in kwargs and kwargs['name'] is not None:
name = kwargs['name']
else: else:
raise ApiError(code="missing_argument", raise ApiError(code="missing_argument",
@ -95,7 +98,8 @@ email(subject="My Subject", recipients="user@example.com", attachments=['Study_A
study_id=study_id, study_id=study_id,
reply_to=reply_to, reply_to=reply_to,
attachment_files=files, attachment_files=files,
workflow_spec_id=workflow_spec_id workflow_spec_id=workflow_spec_id,
name=name
) )
except Exception as e: except Exception as e:
exc_type, exc_value, exc_traceback = sys.exc_info() exc_type, exc_value, exc_traceback = sys.exc_info()

View File

@ -19,7 +19,7 @@ class EmailService(object):
@staticmethod @staticmethod
def add_email(subject, sender, recipients, content, content_html, def add_email(subject, sender, recipients, content, content_html,
cc=None, bcc=None, study_id=None, reply_to=None, attachment_files=None, workflow_spec_id=None): cc=None, bcc=None, study_id=None, reply_to=None, attachment_files=None, workflow_spec_id=None, name=None):
"""We will receive all data related to an email and store it""" """We will receive all data related to an email and store it"""
# Find corresponding study - if any # Find corresponding study - if any
@ -30,7 +30,7 @@ class EmailService(object):
# Create EmailModel # Create EmailModel
email_model = EmailModel(subject=subject, sender=sender, recipients=str(recipients), email_model = EmailModel(subject=subject, sender=sender, recipients=str(recipients),
content=content, content_html=content_html, study=study, content=content, content_html=content_html, study=study,
cc=cc, bcc=bcc, workflow_spec_id=workflow_spec_id) cc=cc, bcc=bcc, workflow_spec_id=workflow_spec_id, name=name)
# Send mail # Send mail
try: try: