Feedback from PR addressed

This commit is contained in:
Carlos Lopez 2020-06-24 22:23:31 -06:00
parent a29b410484
commit a0d877e02f
4 changed files with 29 additions and 28 deletions

View File

@ -132,7 +132,6 @@ class ApprovalService(object):
mail_result = send_ramp_up_approved_email(
'askresearch@virginia.edu',
[pi_user_info.email_address],
approval_id,
f'{approver_info.display_name} - ({approver_info.uid})'
)
if mail_result:
@ -145,7 +144,6 @@ class ApprovalService(object):
mail_result = send_ramp_up_denied_email(
'askresearch@virginia.edu',
[pi_user_info.email_address],
approval_id,
f'{approver_info.display_name} - ({approver_info.uid})'
)
if mail_result:
@ -161,7 +159,6 @@ class ApprovalService(object):
mail_result = send_ramp_up_denied_email_to_approver(
'askresearch@virginia.edu',
approver_email,
approval_id,
f'{pi_user_info.display_name} - ({pi_user_info.uid})',
f'{approver_info.display_name} - ({approver_info.uid})'
)

View File

@ -41,7 +41,7 @@ def send_mail(subject, sender, recipients, content, content_html, study_id=None)
except Exception as e:
return str(e)
def send_ramp_up_submission_email(sender, recipients, approval_id, approver_1, approver_2=None):
def send_ramp_up_submission_email(sender, recipients, approver_1, approver_2=None):
from crc import env
subject = 'Research Ramp-up Plan Submitted'
@ -54,7 +54,7 @@ def send_ramp_up_submission_email(sender, recipients, approval_id, approver_1, a
result = send_mail(subject, sender, recipients, content, content_html)
return result
def send_ramp_up_approval_request_email(sender, recipients, approval_id, primary_investigator):
def send_ramp_up_approval_request_email(sender, recipients, primary_investigator):
from crc import env
subject = 'Research Ramp-up Plan Approval Request'
@ -67,7 +67,7 @@ def send_ramp_up_approval_request_email(sender, recipients, approval_id, primary
result = send_mail(subject, sender, recipients, content, content_html)
return result
def send_ramp_up_approval_request_first_review_email(sender, recipients, approval_id, primary_investigator):
def send_ramp_up_approval_request_first_review_email(sender, recipients, primary_investigator):
from crc import env
subject = 'Research Ramp-up Plan Approval Request'
@ -80,7 +80,7 @@ def send_ramp_up_approval_request_first_review_email(sender, recipients, approva
result = send_mail(subject, sender, recipients, content, content_html)
return result
def send_ramp_up_approved_email(sender, recipients, approval_id, approver_1, approver_2=None):
def send_ramp_up_approved_email(sender, recipients, approver_1, approver_2=None):
from crc import env
subject = 'Research Ramp-up Plan Approved'
@ -93,7 +93,7 @@ def send_ramp_up_approved_email(sender, recipients, approval_id, approver_1, app
result = send_mail(subject, sender, recipients, content, content_html)
return result
def send_ramp_up_denied_email(sender, recipients, approval_id, approver):
def send_ramp_up_denied_email(sender, recipients, approver):
from crc import env
subject = 'Research Ramp-up Plan Denied'
@ -106,7 +106,7 @@ def send_ramp_up_denied_email(sender, recipients, approval_id, approver):
result = send_mail(subject, sender, recipients, content, content_html)
return result
def send_ramp_up_denied_email_to_approver(sender, recipients, approval_id, primary_investigator, approver_2):
def send_ramp_up_denied_email_to_approver(sender, recipients, primary_investigator, approver_2):
from crc import env
subject = 'Research Ramp-up Plan Denied'

View File

@ -13,6 +13,7 @@
---
New request submitted by {{ PIComputingID }}
Email content to be delivered to {{ ApprvlApprvr1 }}
@ -37,17 +38,17 @@ Email content to be delivered to {{ ApprvlApprvr1 }}
</bpmn:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_0tad5ma">
<bpmndi:BPMNEdge id="Flow_1synsig_di" bpmnElement="Flow_1synsig">
<di:waypoint x="215" y="117" />
<di:waypoint x="270" y="117" />
<bpmndi:BPMNEdge id="Flow_08n2npe_di" bpmnElement="Flow_08n2npe">
<di:waypoint x="370" y="117" />
<di:waypoint x="450" y="117" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_1xlrgne_di" bpmnElement="Flow_1xlrgne">
<di:waypoint x="550" y="117" />
<di:waypoint x="662" y="117" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_08n2npe_di" bpmnElement="Flow_08n2npe">
<di:waypoint x="370" y="117" />
<di:waypoint x="450" y="117" />
<bpmndi:BPMNEdge id="Flow_1synsig_di" bpmnElement="Flow_1synsig">
<di:waypoint x="215" y="117" />
<di:waypoint x="270" y="117" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1">
<dc:Bounds x="179" y="99" width="36" height="36" />

View File

@ -1,36 +1,39 @@
from tests.base_test import BaseTest
from crc.models.email import EmailModel
from crc.services.file_service import FileService
from crc.scripts.email import Email
from crc.services.workflow_processor import WorkflowProcessor
from crc.api.common import ApiError
from crc import db
from crc import db, mail
class TestEmailScript(BaseTest):
def test_do_task(self):
# self.load_example_data()
# self.create_reference_document()
workflow = self.create_workflow('email')
# processor = WorkflowProcessor(workflow)
# task = processor.next_task()
# TODO: Replace with proper `complete_form` method from test_tasks
# processor.complete_task(task)
# task = processor.next_task()
task_data = {
'PIComputingID': 'dhf8r',
'ApprvlApprvr1': 'lb3dp'
}
task = self.get_workflow_api(workflow).next_task
with mail.record_messages() as outbox:
self.complete_form(workflow, task, task_data)
self.assertEqual(len(outbox), 1)
self.assertEqual(outbox[0].subject, 'Camunda Email Subject')
# script = Email()
# script.do_task(task, 'Subject', 'PIComputingID', 'ApprvlApprvr1')
# PI is present
self.assertIn(task_data['PIComputingID'], outbox[0].body)
self.assertIn(task_data['PIComputingID'], outbox[0].html)
# TODO: Add proper assertions
self.assertTrue(True)
# Approver is present
self.assertIn(task_data['ApprvlApprvr1'], outbox[0].body)
self.assertIn(task_data['ApprvlApprvr1'], outbox[0].html)
db_emails = EmailModel.query.count()
self.assertEqual(db_emails, 1)