From 620af3602be20f1184d477715add032d5f5f14f9 Mon Sep 17 00:00:00 2001 From: Aurélien Bompard Date: Wed, 14 Nov 2012 17:35:01 +0100 Subject: Adapt to MySQL support splitting out the timezone offset Since the sender's timezone is in a separate column, we can now display the message date in Django's timezone and in the sender's timezone. Future improvement : ask the user for his/her preferred timezone and store it in his/her profile. Then use that to display the dates, instead of Django's server-wide setting. --- hyperkitty/static/css/style.css | 9 +++------ hyperkitty/templates/messages/message.html | 7 ++++--- hyperkitty/templatetags/hk_generic.py | 14 ++++++++++++++ hyperkitty/views/list.py | 1 - 4 files changed, 21 insertions(+), 10 deletions(-) (limited to 'hyperkitty') diff --git a/hyperkitty/static/css/style.css b/hyperkitty/static/css/style.css index 7e5a7f6..87a5946 100644 --- a/hyperkitty/static/css/style.css +++ b/hyperkitty/static/css/style.css @@ -161,10 +161,6 @@ ul.nav.auth { width: 70%; } -.email_date .date { - font-weight: bold; -} - #top_right { position: absolute; right: 20px; @@ -611,8 +607,7 @@ ul.attachments-list li { .email .email_date { font-size: 90%; } -.first_email .email_date span { - display: block; +.first_email .email_date { text-align: right; } .email_date .date { @@ -621,6 +616,8 @@ ul.attachments-list li { .email_date .time { color: rgb(167, 169, 172); margin-left: 0.5em; + border-bottom: 1px dashed rgb(167, 169, 172); + cursor: help; } .add_comment { diff --git a/hyperkitty/templates/messages/message.html b/hyperkitty/templates/messages/message.html index a77c694..d408936 100644 --- a/hyperkitty/templates/messages/message.html +++ b/hyperkitty/templates/messages/message.html @@ -6,13 +6,14 @@
{% ifchanged %} - {{email.date|date:"l, j F"}} + {{email|viewer_date|date:"l, j F"}} {% if unfolded %} - {{email.date|date:"Y"}} + {{email|viewer_date|date:"Y"}} {% endif %} {% endifchanged %} - {{email.date|date:"H:i:s e"}} + {% if unfolded %}
{% endif %} + {{email|viewer_date|date:"H:i:s"}}
{% gravatar_img_for_email email.email 40 %} diff --git a/hyperkitty/templatetags/hk_generic.py b/hyperkitty/templatetags/hk_generic.py index b5f13e6..bfe234c 100644 --- a/hyperkitty/templatetags/hk_generic.py +++ b/hyperkitty/templatetags/hk_generic.py @@ -1,8 +1,10 @@ import datetime import re +from dateutil.tz import tzutc, tzoffset from django import template from django.utils.datastructures import SortedDict +from django.templatetags.tz import localtime register = template.Library() @@ -100,3 +102,15 @@ def escapeemail(text): text = MAILTO_RE.sub(r"\1(a)\2", text) return text.replace("@", u"\uff20") + +@register.filter() +def sender_date(email): + tz = tzoffset(None, email.timezone * 60) + email_date = email.date.replace(tzinfo=tzutc()) + return email_date.astimezone(tz) + + +@register.filter() +def viewer_date(email): + email_date = email.date.replace(tzinfo=tzutc()) + return localtime(email_date) diff --git a/hyperkitty/views/list.py b/hyperkitty/views/list.py index 8fda41d..e17b346 100644 --- a/hyperkitty/views/list.py +++ b/hyperkitty/views/list.py @@ -92,7 +92,6 @@ def archives(request, mlist_fqdn, year=None, month=None, day=None): participants = set() cnt = 0 for thread in threads: - print "*"*10, len(thread), thread.thread_id, thread.starting_email is None participants.update(thread.participants) highestlike = 0 -- cgit