diff --git a/.sonarcloud.properties b/.sonarcloud.properties
index 4394a1bb..f1205436 100644
--- a/.sonarcloud.properties
+++ b/.sonarcloud.properties
@@ -1,7 +1,7 @@
sonar.organization=sartography
sonar.projectKey=sartography_cr-connect-workflow
sonar.host.url=https://sonarcloud.io
-sonar.exclusions=docs/**,config/**,instance/**,migrations/**,postgres/**,readme_images/**,schema/**,templates/**
+sonar.exclusions=crc/templates/*.html,docs/**,config/**,instance/**,migrations/**,postgres/**,readme_images/**,schema/**,templates/**
sonar.sources=crc
sonar.test.inclusions=tests
sonar.python.coverage.reportPaths=coverage.xml
diff --git a/config/default.py b/config/default.py
index 1570811c..598b4966 100644
--- a/config/default.py
+++ b/config/default.py
@@ -15,7 +15,8 @@ JSON_SORT_KEYS = False # CRITICAL. Do not sort the data when returning values
API_TOKEN = environ.get('API_TOKEN', default = 'af95596f327c9ecc007b60414fc84b61')
NAME = "CR Connect Workflow"
-FLASK_PORT = environ.get('PORT0') or environ.get('FLASK_PORT', default="5000")
+DEFAULT_PORT = "5000"
+FLASK_PORT = environ.get('PORT0') or environ.get('FLASK_PORT', default=DEFAULT_PORT)
CORS_ALLOW_ORIGINS = re.split(r',\s*', environ.get('CORS_ALLOW_ORIGINS', default="localhost:4200, localhost:5002"))
TESTING = environ.get('TESTING', default="false") == "true"
PRODUCTION = (environ.get('PRODUCTION', default="false") == "true")
diff --git a/config/testing.py b/config/testing.py
index 5b03cc41..518bc9d3 100644
--- a/config/testing.py
+++ b/config/testing.py
@@ -27,3 +27,6 @@ ADMIN_UIDS = ['dhf8r']
print('### USING TESTING CONFIG: ###')
print('SQLALCHEMY_DATABASE_URI = ', SQLALCHEMY_DATABASE_URI)
print('TESTING = ', TESTING)
+
+from config.default import DEFAULT_PORT
+SERVER_NAME = f'localhost:{DEFAULT_PORT}'
diff --git a/crc/scripts/email.py b/crc/scripts/email.py
index 79f5dc5e..3160dc22 100644
--- a/crc/scripts/email.py
+++ b/crc/scripts/email.py
@@ -7,7 +7,9 @@ from crc import app
from crc.api.common import ApiError
from crc.scripts.script import Script
from crc.services.ldap_service import LdapService
-from crc.services.mails import send_mail
+from crc.services.email_service import EmailService
+
+from flask import render_template, request
class Email(Script):
@@ -25,25 +27,27 @@ email ("My Subject", "dhf8r@virginia.edu", pi.email)
"""
def do_task_validate_only(self, task, *args, **kwargs):
- self.get_subject(task, args)
+ self.get_subject(args)
self.get_email_recipients(task, args)
self.get_content(task)
def do_task(self, task, study_id, workflow_id, *args, **kwargs):
- if len(args) < 1:
+ if len(args) < 2:
raise ApiError(code="missing_argument",
message="Email script requires a subject and at least one email address as arguments")
- subject = args[0]
+ subject = self.get_subject(args)
recipients = self.get_email_recipients(task, args)
- content, content_html = self.get_content(task)
+
if recipients:
- send_mail(
+ content, content_html = self.get_content(task)
+ EmailService.add_email(
subject=subject,
sender=app.config['DEFAULT_SENDER'],
recipients=recipients,
content=content,
- content_html=content_html
+ content_html=content_html,
+ study_id=study_id
)
def check_valid_email(self, email):
@@ -82,7 +86,8 @@ email ("My Subject", "dhf8r@virginia.edu", pi.email)
return emails
- def get_subject(self, task, args):
+ @staticmethod
+ def get_subject(args):
# subject = ''
if len(args[0]) < 1:
raise ApiError(code="missing_argument",
@@ -101,4 +106,10 @@ email ("My Subject", "dhf8r@virginia.edu", pi.email)
template = Template(content)
rendered = template.render(task.data)
rendered_markdown = markdown.markdown(rendered).replace('\n', '
')
- return rendered, rendered_markdown
+ wrapped = self.get_cr_connect_wrapper(rendered_markdown)
+
+ return rendered, wrapped
+
+ @staticmethod
+ def get_cr_connect_wrapper(email_body):
+ return render_template('mail_content_template.html', email_body=email_body, base_url=request.base_url)
diff --git a/crc/static/uva_rotunda.svg b/crc/static/uva_rotunda.svg
new file mode 100644
index 00000000..6ef09251
--- /dev/null
+++ b/crc/static/uva_rotunda.svg
@@ -0,0 +1,145 @@
+
+
diff --git a/crc/templates/mail_content_template.html b/crc/templates/mail_content_template.html
new file mode 100644
index 00000000..76ea2b7a
--- /dev/null
+++ b/crc/templates/mail_content_template.html
@@ -0,0 +1,10 @@
+{% extends "mail_main_template.html" %}
+{% block content %}
+
+ {{ email_body | safe }}
+
+{% endblock %}
+{% block footer %}
+ {{ super() }}
+ Ramp-Up Toolkit Configurator - University of Virginia
+{% endblock %}}
diff --git a/crc/templates/mail_main_template.html b/crc/templates/mail_main_template.html
new file mode 100644
index 00000000..62e3ba97
--- /dev/null
+++ b/crc/templates/mail_main_template.html
@@ -0,0 +1,421 @@
+
+
+
+
+
+
+
+ CR-Connect Email
+
+ Research Ramp-Up Toolkit
+
+
+
+
+
+ |
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {% block content %}{% endblock %}
+ |
+
+
+ |
+
+
+
+
+
+
+
+
+
+
+
+ |
+ |
+
+
+
+