From 868435f85daab097714006aa07c72da8bad8658b Mon Sep 17 00:00:00 2001 From: Miles Calabresi Date: Sat, 21 Nov 2015 21:12:39 -0500 Subject: [PATCH 01/14] Create default_email_html.txt (chapter request) add a default template that can be overridden via /admin/ for chapters who regularly use HTML templates and don't want to copy-paste into the box --- esp/templates/email/default_email_html.txt | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 esp/templates/email/default_email_html.txt diff --git a/esp/templates/email/default_email_html.txt b/esp/templates/email/default_email_html.txt new file mode 100644 index 0000000000..9e8a93e19c --- /dev/null +++ b/esp/templates/email/default_email_html.txt @@ -0,0 +1,5 @@ + +{% autoescape off %} +{{ msgbdy }} +{% endautoescape %} + From d584bf034e05eefc37f0b43d5b527827fc720e67 Mon Sep 17 00:00:00 2001 From: Miles Calabresi Date: Sat, 21 Nov 2015 22:24:30 -0500 Subject: [PATCH 02/14] use default HTML email template per a chapter request, this change makes the comm module use a default email template to wrap around all messages sent through the comm panel. Now users just type in HTML into the comm panel and it is automatically put into a template set via template overrides (default is just to put tags around the message typed into the comm panel) --- esp/esp/program/modules/handlers/commmodule.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/esp/esp/program/modules/handlers/commmodule.py b/esp/esp/program/modules/handlers/commmodule.py index a517da108c..18ec6e9247 100644 --- a/esp/esp/program/modules/handlers/commmodule.py +++ b/esp/esp/program/modules/handlers/commmodule.py @@ -109,6 +109,11 @@ def commprev(self, request, tl, one, two, module, extra, prog): esp_firstuser = ESPUser(firstuser) contextdict = {'user' : ActionHandler(esp_firstuser, esp_firstuser), 'program': ActionHandler(self.program, esp_firstuser) } + + htmlbody = unicode(loader.get_template('email/default_email_html.txt').render(DjangoContext({'msgbdy': body, + 'user': ActionHandler(esp_firstuser, esp_firstuser) + 'program': ActionHandler(self.program, esp_firstuser)}))) + renderedtext = Template(htmlbody).render(DjangoContext(contextdict)) return render_to_response(self.baseDir()+'preview.html', request, @@ -175,7 +180,10 @@ def commfinal(self, request, tl, one, two, module, extra, prog): sendto_fn_name = sendto_fn_name, sender = fromemail, creator = request.user, - msgtext = body, + msgtext = unicode(loader.get_template('email/default_email_html.txt').render(DjangoContext( + {'msgbdy': body, + 'user': request.user, + 'program': self.program }))), special_headers_dict = { 'Reply-To': replytoemail, }, ) From eff3d7b477fb32c6060c82a9a46e0d01935e9f10 Mon Sep 17 00:00:00 2001 From: Miles Calabresi Date: Sat, 21 Nov 2015 22:33:14 -0500 Subject: [PATCH 03/14] fixes missing comma --- esp/esp/program/modules/handlers/commmodule.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/esp/esp/program/modules/handlers/commmodule.py b/esp/esp/program/modules/handlers/commmodule.py index 18ec6e9247..bfb03cd59e 100644 --- a/esp/esp/program/modules/handlers/commmodule.py +++ b/esp/esp/program/modules/handlers/commmodule.py @@ -111,7 +111,7 @@ def commprev(self, request, tl, one, two, module, extra, prog): 'program': ActionHandler(self.program, esp_firstuser) } htmlbody = unicode(loader.get_template('email/default_email_html.txt').render(DjangoContext({'msgbdy': body, - 'user': ActionHandler(esp_firstuser, esp_firstuser) + 'user': ActionHandler(esp_firstuser, esp_firstuser), 'program': ActionHandler(self.program, esp_firstuser)}))) renderedtext = Template(htmlbody).render(DjangoContext(contextdict)) From 594b670b7cf9c99c4d5e5e616afbd88d8e1c74b1 Mon Sep 17 00:00:00 2001 From: Miles Calabresi Date: Sat, 21 Nov 2015 22:41:57 -0500 Subject: [PATCH 04/14] add instructions for admins to use new template --- esp/templates/program/modules/commmodule/step2.html | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/esp/templates/program/modules/commmodule/step2.html b/esp/templates/program/modules/commmodule/step2.html index 18de692033..c07c061c70 100644 --- a/esp/templates/program/modules/commmodule/step2.html +++ b/esp/templates/program/modules/commmodule/step2.html @@ -38,7 +38,8 @@

Step 2:

Please write your email/message now. Note that you can use {{ parameter }} to enter a parameter into the text of the message—the parameters are listed below. -

Tip: If you would like to send your message in HTML format, wrap your entire message body in <html> and </html> tags.

+

Tip: The default {{ settings.ORGANIZATION_SHORT_NAME }} template (which you can modify here) is automatically wrapped around your message below. +Don't forget to write the body in HTML, but no need for <html> and </html> tags.

From 3284a7604270b9302c6ebeae0e255f77c11f8602 Mon Sep 17 00:00:00 2001 From: Miles Calabresi Date: Sat, 21 Nov 2015 22:54:33 -0500 Subject: [PATCH 05/14] fixes missing import in commmodule.py --- esp/esp/program/modules/handlers/commmodule.py | 1 + 1 file changed, 1 insertion(+) diff --git a/esp/esp/program/modules/handlers/commmodule.py b/esp/esp/program/modules/handlers/commmodule.py index bfb03cd59e..7f7999f2ca 100644 --- a/esp/esp/program/modules/handlers/commmodule.py +++ b/esp/esp/program/modules/handlers/commmodule.py @@ -44,6 +44,7 @@ from django.template import Context as DjangoContext from esp.middleware.threadlocalrequest import AutoRequestContext as Context from esp.middleware import ESPError +from django.template import loader class CommModule(ProgramModuleObj): """ Want to email all ESP students within a 60 mile radius of NYC? From eda9ad5ef39a44c859918633569f098b9bc6c807 Mon Sep 17 00:00:00 2001 From: Miles Calabresi Date: Thu, 4 Aug 2016 23:27:38 -0400 Subject: [PATCH 06/14] add (curently inactive) radio buttons for text vs HTML --- .../program/modules/commmodule/step2.html | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/esp/templates/program/modules/commmodule/step2.html b/esp/templates/program/modules/commmodule/step2.html index c07c061c70..22115ed56e 100644 --- a/esp/templates/program/modules/commmodule/step2.html +++ b/esp/templates/program/modules/commmodule/step2.html @@ -37,12 +37,22 @@

Step 2:


Please write your email/message now. Note that you can use {{ parameter }} to enter a parameter into the text of the message—the parameters are listed below. - -

Tip: The default {{ settings.ORGANIZATION_SHORT_NAME }} template (which you can modify here) is automatically wrapped around your message below. -Don't forget to write the body in HTML, but no need for <html> and </html> tags.

+The default {{ settings.ORGANIZATION_SHORT_NAME }} template (which you can +modify +here) +is automatically wrapped around your message below. +You can choose to write the body in either plain text or HTML. +If you choose to use HTML, there is no need for <html> and </html> +tags because they're are included in the wrapper template. +If you choose plain text, do not try to use any HTML tags for +whitespace.

+
+ + Plain Text
+ HTML