From f3d14304e58e515570d42bb6a8e4ceab78db12e1 Mon Sep 17 00:00:00 2001
From: Todd Dembrey <todd.dembrey@torchbox.com>
Date: Thu, 26 Jul 2018 10:41:21 +0100
Subject: [PATCH] Simplify the context of the new submission template

---
 opentech/apply/activity/messaging.py             |  9 +--------
 .../funds/templates/funds/email/confirmation.txt | 16 +++++++++-------
 2 files changed, 10 insertions(+), 15 deletions(-)

diff --git a/opentech/apply/activity/messaging.py b/opentech/apply/activity/messaging.py
index 34b07c2fe..143234c8d 100644
--- a/opentech/apply/activity/messaging.py
+++ b/opentech/apply/activity/messaging.py
@@ -151,14 +151,7 @@ class EmailAdapter(AdapterBase):
     }
 
     def email_from_submission(self, submission, **kwargs):
-        email_data = submission.page.specific
-        context = {
-            'name': submission.user.get_full_name(),
-            'email': submission.user.email,
-            'project_name': submission.form_data.get('title'),
-            'extra_text': email_data.confirmation_text_extra,
-            'fund_type': email_data.title,
-        }
+        context = {'submission': submission}
         return render_to_string('funds/email/confirmation.txt', context)
 
     def send_message(self, message, submission, **kwargs):
diff --git a/opentech/apply/funds/templates/funds/email/confirmation.txt b/opentech/apply/funds/templates/funds/email/confirmation.txt
index 6756377e3..1d08ad5b3 100644
--- a/opentech/apply/funds/templates/funds/email/confirmation.txt
+++ b/opentech/apply/funds/templates/funds/email/confirmation.txt
@@ -1,16 +1,18 @@
-Dear {{ name|default:"applicant" }},
+Dear {{ submission.user.get_full_name|default:"applicant" }},
 
-We appreciate your {{ fund_type }} 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 {{ fund_type }} application.
+{% 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.
 You can find more information about our support options, review process and selection criteria on our website.
 
-{% if extra_text %}{{ extra_text }}{% endif %}
+{{ email_context.confirmation_text_text }}
+{% endwith %}
 
 If you have any questions, please email us at info@opentechfund.org.
 
-{% if project_name %}Project name: {{ project_name }}{% endif %}
-{% if name %}Contact name: {{ name }}{% endif %}
-{% if email %}Contact email: {{ email }}{% endif %}
+Project name: {{ submission.title }}
+Contact name: {{ submission.user.get_full_name }}
+Contact email: {{ submission.user.email }}
 
 Thanks again,
 The OTF Team
-- 
GitLab