Fix date rendering

This commit is contained in:
Aarni Halinen
2018-05-09 22:16:40 +03:00
parent ab6b7d19fb
commit 9e0d911f7b
3 changed files with 4 additions and 21 deletions
+3 -2
View File
@@ -4,6 +4,7 @@ import django_tables2 as tables
from django.utils.translation import ugettext as _
from django.core.exceptions import ObjectDoesNotExist
from django.db.models import F, OuterRef, Subquery
from django.utils import timezone
from members.models import Member, Payment, Request
@@ -25,9 +26,9 @@ class MemberTable(tables.Table):
def render_last_paid(self, record):
try:
return record.payments.filter(member=record).latest('date').date.strftime('%e.%m.%Y %H:%M')
return timezone.localtime(record.payments.filter(member=record).latest('date').date).strftime('%-d.%-m.%Y %H:%M')
except ObjectDoesNotExist:
return record.created.strftime('%e.%m.%Y %H:%M') + _(" (not paid)")
return timezone.localtime(record.created).strftime('%-d.%-m.%Y %H:%M') + _(" (not paid)")
def order_last_paid(self, queryset, is_descending):
latest = Payment.objects.filter(member=OuterRef('pk')).order_by('-date')
-18
View File
@@ -1,18 +0,0 @@
{% extends "members:base.html" %}
{% load static %}
{% load i18n %}
{% block content %}
<div>
<div>
<h3>{% trans "Error" %}</h3>
</div>
<div class="alert alert-danger">
{{ error|safe }}
</div>
<div>
<button onclick="window.history.back();" class="btn btn-primary">{% trans "Back" %}</button>
</div>
</div>
{% endblock content %}