Commit 07c07af5cef675806c16a3402baf394359a31d79

Authored by Antoine Goutenoir
1 parent 85ddfda9
Exists in master

Add an email template for the "request run" event.

flaskr/controllers/main_controller.py
... ... @@ -28,7 +28,7 @@ from flaskr.core import (
28 28 get_emission_models,
29 29 increment_hit_counter,
30 30 )
31   -from flaskr.content import content
  31 +from flaskr.content import content, base_url
32 32  
33 33 from wtforms import validators
34 34  
... ... @@ -51,7 +51,6 @@ OUT_ENCODING = 'utf-8'
51 51  
52 52 pi_email = "didier.barret@irap.omp.eu" # todo: move to content YAML or .env
53 53 # pi_email = "goutte@protonmail.com"
54   -base_url = "https://travel-footprint-calculator.irap.omp.eu/"
55 54  
56 55 # -----------------------------------------------------------------------------
57 56  
... ... @@ -243,7 +242,11 @@ def estimate(): # register new estimation request, more accurately
243 242 send_email(
244 243 to_recipient=pi_email,
245 244 subject="[TCFM] New Estimation Request: %s" % estimation.public_id,
246   - message="TODO"
  245 + message=render_template(
  246 + 'email/run_requested.html',
  247 + base_url=base_url,
  248 + estimation=estimation,
  249 + )
247 250 )
248 251  
249 252 flash("Estimation request submitted successfully.", "success")
... ...
flaskr/templates/email/run_requested.html 0 → 100644
... ... @@ -0,0 +1,67 @@
  1 +{% extends "email/base.html" %}
  2 +
  3 +{% block content %}
  4 +<p>
  5 + The run
  6 +{% if estimation.run_name %}
  7 + <strong>"{{ estimation.run_name }}"</strong>
  8 +{% endif %}
  9 + <code>{{ estimation.public_id }}</code> has been requested.
  10 +
  11 + It will be
  12 + <strong><a href="{{ estimation.link }}">available here</a></strong>
  13 + when it's done.
  14 +</p>
  15 +
  16 +<hr>
  17 +
  18 +{# Styles are embedded, because that's how it works with emailing. #}
  19 +
  20 +<table>
  21 + <tbody>
  22 + <tr>
  23 + <td style="padding-right: 30px;">
  24 + Author
  25 + </td>
  26 + <td>
  27 + <pre>{{ estimation.author_name }}</pre>
  28 + </td>
  29 + </tr>
  30 + <tr>
  31 + <td style="padding-right: 30px;">
  32 + {{ estimation.origins_count }}
  33 + Origin{% if estimation.origins_count > 1 %}s{% endif %}
  34 + </td>
  35 + <td>
  36 + <pre>
  37 +
  38 +{{ estimation.origin_addresses | truncate(1024, true, '…') }}
  39 + </pre>
  40 + </td>
  41 + </tr>
  42 + <tr>
  43 + <td style="padding-right: 30px;">
  44 + {{ estimation.destinations_count }}
  45 + Destination{% if estimation.destinations_count > 1 %}s{% endif %}
  46 + </td>
  47 + <td>
  48 + <pre>
  49 +
  50 +{{ estimation.destination_addresses | truncate(1024, true, '…') }}
  51 + </pre>
  52 + </td>
  53 + </tr>
  54 + <tr>
  55 + <td style="padding-right: 30px;">
  56 + Models
  57 + </td>
  58 + <td>
  59 + <pre>
  60 +
  61 +{{ estimation.models_slugs }}
  62 + </pre>
  63 + </td>
  64 + </tr>
  65 + </tbody>
  66 +</table>
  67 +{% endblock %}
... ...