From 07c07af5cef675806c16a3402baf394359a31d79 Mon Sep 17 00:00:00 2001 From: Antoine Goutenoir Date: Fri, 17 Apr 2020 21:04:13 +0200 Subject: [PATCH] Add an email template for the "request run" event. --- flaskr/controllers/main_controller.py | 9 ++++++--- flaskr/templates/email/run_requested.html | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+), 3 deletions(-) create mode 100644 flaskr/templates/email/run_requested.html diff --git a/flaskr/controllers/main_controller.py b/flaskr/controllers/main_controller.py index 66f495f..cabef6d 100644 --- a/flaskr/controllers/main_controller.py +++ b/flaskr/controllers/main_controller.py @@ -28,7 +28,7 @@ from flaskr.core import ( get_emission_models, increment_hit_counter, ) -from flaskr.content import content +from flaskr.content import content, base_url from wtforms import validators @@ -51,7 +51,6 @@ OUT_ENCODING = 'utf-8' pi_email = "didier.barret@irap.omp.eu" # todo: move to content YAML or .env # pi_email = "goutte@protonmail.com" -base_url = "https://travel-footprint-calculator.irap.omp.eu/" # ----------------------------------------------------------------------------- @@ -243,7 +242,11 @@ def estimate(): # register new estimation request, more accurately send_email( to_recipient=pi_email, subject="[TCFM] New Estimation Request: %s" % estimation.public_id, - message="TODO" + message=render_template( + 'email/run_requested.html', + base_url=base_url, + estimation=estimation, + ) ) flash("Estimation request submitted successfully.", "success") diff --git a/flaskr/templates/email/run_requested.html b/flaskr/templates/email/run_requested.html new file mode 100644 index 0000000..0b865f1 --- /dev/null +++ b/flaskr/templates/email/run_requested.html @@ -0,0 +1,67 @@ +{% extends "email/base.html" %} + +{% block content %} +

+ The run +{% if estimation.run_name %} + "{{ estimation.run_name }}" +{% endif %} + {{ estimation.public_id }} has been requested. + + It will be + available here + when it's done. +

+ +
+ +{# Styles are embedded, because that's how it works with emailing. #} + + + + + + + + + + + + + + + + + + + + +
+ Author + +
{{ estimation.author_name }}
+
+ {{ estimation.origins_count }} + Origin{% if estimation.origins_count > 1 %}s{% endif %} + +
+
+{{ estimation.origin_addresses | truncate(1024, true, '…') }}
+            
+
+ {{ estimation.destinations_count }} + Destination{% if estimation.destinations_count > 1 %}s{% endif %} + +
+
+{{ estimation.destination_addresses | truncate(1024, true, '…') }}
+            
+
+ Models + +
+
+{{ estimation.models_slugs }}
+            
+
+{% endblock %} -- libgit2 0.21.2