From 885abdf5d293830fb6a6b884435a593e33b06a00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa?= Date: Thu, 12 Apr 2018 13:32:59 +0200 Subject: [PATCH] Format due dates in email templates --- taiga/front/templatetags/functions.py | 7 +++++ .../emails/includes/fields_diff-html.jinja | 27 +++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/taiga/front/templatetags/functions.py b/taiga/front/templatetags/functions.py index db8a6616..2177afe6 100644 --- a/taiga/front/templatetags/functions.py +++ b/taiga/front/templatetags/functions.py @@ -16,6 +16,7 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . +from datetime import datetime from django_jinja import library from django_sites import get_by_id as get_site_by_id @@ -31,3 +32,9 @@ def resolve(type, *args): scheme = site.scheme and "{0}:".format(site.scheme) or "" url = urls[type].format(*args) return url_tmpl.format(scheme=scheme, domain=site.domain, url=url) + + +@library.filter(name="date") +def format_date(value, *args): + date_value = datetime.strptime(value, '%Y-%m-%d') + return date_value.strftime('%d %b %Y') diff --git a/taiga/projects/history/templates/emails/includes/fields_diff-html.jinja b/taiga/projects/history/templates/emails/includes/fields_diff-html.jinja index 9d3473e7..ddce4468 100644 --- a/taiga/projects/history/templates/emails/includes/fields_diff-html.jinja +++ b/taiga/projects/history/templates/emails/includes/fields_diff-html.jinja @@ -149,6 +149,33 @@ {% endif %} + {# ASSIGNED TO #} + {% elif field_name == "due_date" %} + + +

{{ verbose_name(obj_class, field_name) }}

+ + + {% if values.0 != None and values.0 != "" %} + {{ _("from") }}
+ {{ values.0|date }} + {% else %} + {{ _("from") }}
+ {{ _("Not set") }} + {% endif %} + + + + + {% if values.1 != None and values.1 != "" %} + {{ _("to") }}
+ {{ values.1|date }} + {% else %} + {{ _("to") }}
+ {{ _("Not set") }} + {% endif %} + + {# * #} {% else %}