From 0e82b8aa70c5d60b389cc5e9877e2d2103248d47 Mon Sep 17 00:00:00 2001
From: Todd Dembrey <todd.dembrey@torchbox.com>
Date: Fri, 27 Jul 2018 10:30:38 +0100
Subject: [PATCH] Refactor the emails to have a base template

---
 opentech/apply/activity/messaging.py              |  5 +++--
 .../activity/templates/messages/email/base.html   | 14 ++++++++++++++
 .../templates/messages/email/comment.html         | 15 +++------------
 .../funds/templates/funds/email/confirmation.html | 15 +++------------
 4 files changed, 23 insertions(+), 26 deletions(-)
 create mode 100644 opentech/apply/activity/templates/messages/email/base.html

diff --git a/opentech/apply/activity/messaging.py b/opentech/apply/activity/messaging.py
index 1a7c2c8fb..f8ebba4c2 100644
--- a/opentech/apply/activity/messaging.py
+++ b/opentech/apply/activity/messaging.py
@@ -151,11 +151,12 @@ class EmailAdapter(AdapterBase):
         MESSAGES.COMMENT: 'notify_comment',
     }
 
-    def notify_comment(self, comment, **kwargs):
+    def notify_comment(self, **kwargs):
+        comment = kwargs['comment']
         if not comment.private:
             return render_to_string('messages/email/comment.html', kwargs)
 
-    def email_from_submission(self, submission, **kwargs):
+    def email_from_submission(self, **kwargs):
         return render_to_string('funds/email/confirmation.html', kwargs)
 
     def send_message(self, message, submission, **kwargs):
diff --git a/opentech/apply/activity/templates/messages/email/base.html b/opentech/apply/activity/templates/messages/email/base.html
new file mode 100644
index 000000000..211ed59d6
--- /dev/null
+++ b/opentech/apply/activity/templates/messages/email/base.html
@@ -0,0 +1,14 @@
+Dear {{ submission.user.get_full_name|default:"applicant" }},
+
+{% block content %}{% endblock %}
+
+You can access your application here: {{ request.scheme }}://{{ request.get_host }}{{ submission.get_absolute_url }}
+
+If you have any questions, please email us at info@opentechfund.org.
+
+Kind Regards,
+The OTF Team
+
+--
+Open Technology Fund
+https://www.opentech.fund/
diff --git a/opentech/apply/activity/templates/messages/email/comment.html b/opentech/apply/activity/templates/messages/email/comment.html
index a6e29285b..c5714b9a5 100644
--- a/opentech/apply/activity/templates/messages/email/comment.html
+++ b/opentech/apply/activity/templates/messages/email/comment.html
@@ -1,16 +1,7 @@
-Dear {{ submission.user.get_full_name|default:"applicant" }},
+{% extends "messages/email/base.html" %}
 
+{% block content %}
 There has been a new comment on your application: {{ submission.title }}
 
 {{ comment.message }}
-
-You can access your application here: {{ request.scheme }}://{{ request.get_host }}{{ submission.get_absolute_url }}
-
-If you have any questions, please email us at info@opentechfund.org.
-
-Kind Regards,
-The OTF Team
-
---
-Open Technology Fund
-https://www.opentech.fund/
+{% endblock %}
diff --git a/opentech/apply/funds/templates/funds/email/confirmation.html b/opentech/apply/funds/templates/funds/email/confirmation.html
index f778f2c2f..f517b72a8 100644
--- a/opentech/apply/funds/templates/funds/email/confirmation.html
+++ b/opentech/apply/funds/templates/funds/email/confirmation.html
@@ -1,5 +1,6 @@
-Dear {{ submission.user.get_full_name|default:"applicant" }},
+{% extends "messages/email/base.html" %}
 
+{% block content %}
 {% with email_context=submission.page.specific %}
 We appreciate your {{ email_context.title }} application submission to the Open Technology Fund. We will review and reply to your
 submission as quickly as possible. Our reply will have the next steps for your {{ email_context.title }} application.
@@ -8,17 +9,7 @@ You can find more information about our support options, review process and sele
 {{ email_context.confirmation_text_text }}
 {% endwith %}
 
-If you have any questions, please email us at info@opentechfund.org.
-
-You can access your application at {{ submission.get_absolute_url }}
-
 Project name: {{ submission.title }}
 Contact name: {{ submission.user.get_full_name }}
 Contact email: {{ submission.user.email }}
-
-Thanks again,
-The OTF Team
-
---
-Open Technology Fund
-https://www.opentech.fund/
+{% endblock %}
-- 
GitLab