Merge pull request #410 from sartography/timer-event-issues-511

Timer event issues #511
This commit is contained in:
Dan Funk 2021-10-22 14:04:18 -04:00 committed by GitHub
commit 5ab53c50f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 2 deletions

View File

@ -12,6 +12,8 @@ from crc.services.email_service import EmailService
from crc.services.ldap_service import LdapService
from crc.services.study_service import StudyService
import datetime
class Email(Script):
"""Send an email from a script task, as part of a workflow.
@ -43,7 +45,12 @@ email(subject="My Subject", recipients="user@example.com", attachments=['Study_A
subject = self.get_subject(kwargs['subject'])
recipients = self.get_email_addresses(kwargs['recipients'], study_id)
content, content_html = EmailService().get_rendered_content(task.task_spec.documentation, task.data)
return EmailModel(subject=subject, recipients=recipients, content=content, content_html=content_html)
email_model = EmailModel(subject=subject,
recipients=recipients,
content=content,
content_html=content_html,
timestamp=datetime.datetime.utcnow())
return EmailModelSchema().dump(email_model)
def do_task(self, task, study_id, workflow_id, *args, **kwargs):

View File

@ -282,7 +282,12 @@ class WorkflowService(object):
# jsonify, and de-jsonify the data to mimic how data will be returned from the front end for forms and assures
# we aren't generating something that can't be serialized.
form_data_string = json.dumps(form_data)
try:
form_data_string = json.dumps(form_data)
except TypeError as te:
raise ApiError.from_task(code='serialize_error',
message=f'Something cannot be serialized. Message is: {te}',
task=task)
task.data.update(json.loads(form_data_string))
@staticmethod