Format due dates in email templates

remotes/origin/3.4.0rc
Daniel García 2018-04-12 13:32:59 +02:00
parent 4e58bf7413
commit 885abdf5d2
2 changed files with 34 additions and 0 deletions

View File

@ -16,6 +16,7 @@
# You should have received a copy of the GNU Affero General Public License # You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
from datetime import datetime
from django_jinja import library from django_jinja import library
from django_sites import get_by_id as get_site_by_id 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 "" scheme = site.scheme and "{0}:".format(site.scheme) or ""
url = urls[type].format(*args) url = urls[type].format(*args)
return url_tmpl.format(scheme=scheme, domain=site.domain, url=url) 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')

View File

@ -149,6 +149,33 @@
{% endif %} {% endif %}
</td> </td>
</tr> </tr>
{# ASSIGNED TO #}
{% elif field_name == "due_date" %}
<tr>
<td valign="middle" rowspan="2" class="update-row-name">
<h3>{{ verbose_name(obj_class, field_name) }}</h3>
</td>
<td valign="top" class="update-row-from">
{% if values.0 != None and values.0 != "" %}
<span>{{ _("from") }}</span><br>
<strong>{{ values.0|date }}</strong>
{% else %}
<span>{{ _("from") }}</span><br>
<strong>{{ _("Not set") }}</strong>
{% endif %}
</td>
</tr>
<tr>
<td valign="top">
{% if values.1 != None and values.1 != "" %}
<span>{{ _("to") }}</span><br>
<strong>{{ values.1|date }}</strong>
{% else %}
<span>{{ _("to") }}</span><br>
<strong>{{ _("Not set") }}</strong>
{% endif %}
</td>
</tr>
{# * #} {# * #}
{% else %} {% else %}
<tr> <tr>