From b52343903c69bf75c6f6d9d5a0cfba7063cb31bc Mon Sep 17 00:00:00 2001 From: mike cullerton Date: Mon, 25 Apr 2022 15:38:15 -0400 Subject: [PATCH] Add `name` to email script and email_service --- crc/scripts/email.py | 6 +++++- crc/services/email_service.py | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/crc/scripts/email.py b/crc/scripts/email.py index 8fa8ba0d..d310fbf1 100644 --- a/crc/scripts/email.py +++ b/crc/scripts/email.py @@ -63,6 +63,7 @@ email(subject="My Subject", recipients="user@example.com", attachments=['Study_A bcc = [] reply_to = None files = None + name = None if 'cc' in kwargs and kwargs['cc'] is not None: cc = self.get_email_addresses(kwargs['cc'], study_id) 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 '' if 'attachments' in kwargs and kwargs['attachments'] is not None and kwargs['attachments'] != '': files = self.get_files(kwargs['attachments'], study_id) + if 'name' in kwargs and kwargs['name'] is not None: + name = kwargs['name'] else: raise ApiError(code="missing_argument", @@ -95,7 +98,8 @@ email(subject="My Subject", recipients="user@example.com", attachments=['Study_A study_id=study_id, reply_to=reply_to, attachment_files=files, - workflow_spec_id=workflow_spec_id + workflow_spec_id=workflow_spec_id, + name=name ) except Exception as e: exc_type, exc_value, exc_traceback = sys.exc_info() diff --git a/crc/services/email_service.py b/crc/services/email_service.py index c917b916..15e84279 100644 --- a/crc/services/email_service.py +++ b/crc/services/email_service.py @@ -19,7 +19,7 @@ class EmailService(object): @staticmethod 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""" # Find corresponding study - if any @@ -30,7 +30,7 @@ class EmailService(object): # Create EmailModel email_model = EmailModel(subject=subject, sender=sender, recipients=str(recipients), 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 try: