diff --git a/taiga/front/templatetags/functions.py b/taiga/front/templatetags/functions.py index 2177afe6..4810715f 100644 --- a/taiga/front/templatetags/functions.py +++ b/taiga/front/templatetags/functions.py @@ -16,7 +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 +import datetime as dt from django_jinja import library from django_sites import get_by_id as get_site_by_id @@ -34,7 +34,7 @@ def resolve(type, *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') +@library.filter(name="parse_and_format_date") +def parse_and_format_date(value, *args): + date_value = dt.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 2e6138e7..452c7f92 100644 --- a/taiga/projects/history/templates/emails/includes/fields_diff-html.jinja +++ b/taiga/projects/history/templates/emails/includes/fields_diff-html.jinja @@ -149,7 +149,7 @@ {% endif %} - {# ASSIGNED TO #} + {# DUE DATE #} {% elif field_name == "due_date" %} @@ -158,7 +158,7 @@ {% if values.0 != None and values.0 != "" %} {{ _("from") }}
- {{ values.0|date }} + {{ values.0|parse_and_format_date }} {% else %} {{ _("from") }}
{{ _("Not set") }} @@ -169,7 +169,7 @@ {% if values.1 != None and values.1 != "" %} {{ _("to") }}
- {{ values.1|date }} + {{ values.1|parse_and_format_date }} {% else %} {{ _("to") }}
{{ _("Not set") }} diff --git a/tests/integration/test_emails.py b/tests/integration/test_emails.py new file mode 100644 index 00000000..4ea8d853 --- /dev/null +++ b/tests/integration/test_emails.py @@ -0,0 +1,33 @@ +# -*- coding: utf-8 -*- +# Copyright (C) 2018 Miguel González +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +import pytest + +from django.core.management import call_command + +from .. import factories as f + + +@pytest.mark.django_db +def test_emails(): + # Membership invitation + m = f.MembershipFactory.create() + m.user = None + m.save() + + # Regular membership + f.MembershipFactory.create() + + # f.UserFactory.create() + call_command('test_emails', 'none@example.test')