diff --git a/accounts/models.py b/accounts/models.py index 623a6bbe7..b431d3c4b 100644 --- a/accounts/models.py +++ b/accounts/models.py @@ -673,13 +673,16 @@ def send_announcement_email(cls, user: User, study, children): return announcement_message def send_as_email(self): + lab_email = self.related_study.lab.contact_email + context = { "base_url": settings.BASE_URL, "custom_message": mark_safe(self.body), + "lab_name": self.related_study.lab.name, + "lab_email": lab_email, + "study_name": self.related_study.name, } - lab_email = self.related_study.lab.contact_email - recipient_email_list = list(self.recipients.values_list("username", flat=True)) for to_email in recipient_email_list: diff --git a/studies/templates/emails/custom_email.html b/studies/templates/emails/custom_email.html index 6c67c5001..a60e52e2a 100644 --- a/studies/templates/emails/custom_email.html +++ b/studies/templates/emails/custom_email.html @@ -1,5 +1,6 @@ {% extends "emails/base.html" %} {% block content %} + {% include "emails/custom_email_header.html" %} {% autoescape off %} {{ custom_message }} {% endautoescape %} diff --git a/studies/templates/emails/custom_email.txt b/studies/templates/emails/custom_email.txt index 818479e53..8b9e2b5c7 100644 --- a/studies/templates/emails/custom_email.txt +++ b/studies/templates/emails/custom_email.txt @@ -1,4 +1,6 @@ {% extends "emails/base.txt" %} + {% block content %} +{% include "emails/custom_email_header.txt" %} {{ custom_message|striptags }} {% endblock content %} diff --git a/studies/templates/emails/custom_email_header.html b/studies/templates/emails/custom_email_header.html new file mode 100644 index 000000000..b5c043297 --- /dev/null +++ b/studies/templates/emails/custom_email_header.html @@ -0,0 +1 @@ +
{% include "emails/custom_email_header.txt" %}
diff --git a/studies/templates/emails/custom_email_header.txt b/studies/templates/emails/custom_email_header.txt new file mode 100644 index 000000000..13cac2e4a --- /dev/null +++ b/studies/templates/emails/custom_email_header.txt @@ -0,0 +1 @@ +This is an email from {{ lab_name }} for "{{ study_name }}". You may reply to this email to message directly with the researchers at {{ lab_name }} or email them at {{ lab_email }} if you have other questions. diff --git a/studies/templates/studies/study_participant_contact.html b/studies/templates/studies/study_participant_contact.html index 4c748c2ad..a5df8df52 100644 --- a/studies/templates/studies/study_participant_contact.html +++ b/studies/templates/studies/study_participant_contact.html @@ -143,6 +143,15 @@ +All particiapant emails will see the following header when they're contacted from this form:
+ + {% include "emails/custom_email_header.html" with lab_name=study.lab.name study_name=study.name lab_email=study.lab.contact_email %} + +