diff options
author | Aurélien Bompard <aurelien@bompard.org> | 2013-05-27 20:52:03 +0200 |
---|---|---|
committer | Aurélien Bompard <aurelien@bompard.org> | 2013-05-27 21:18:29 +0200 |
commit | dad66ad5a2c8a9645e0127e09283082f3c439a28 (patch) | |
tree | a345405f0d4228b246f4b6dce3d00dcda1e06d91 /hyperkitty/views | |
parent | 2a84b82a17e6986b3265d958f89d562c241a7a80 (diff) | |
download | hyperkitty-dad66ad5a2c8a9645e0127e09283082f3c439a28.tar.gz hyperkitty-dad66ad5a2c8a9645e0127e09283082f3c439a28.tar.xz hyperkitty-dad66ad5a2c8a9645e0127e09283082f3c439a28.zip |
Rework the display of email datetimes using timezones
Diffstat (limited to 'hyperkitty/views')
-rw-r--r-- | hyperkitty/views/accounts.py | 3 | ||||
-rw-r--r-- | hyperkitty/views/list.py | 6 | ||||
-rw-r--r-- | hyperkitty/views/thread.py | 3 |
3 files changed, 8 insertions, 4 deletions
diff --git a/hyperkitty/views/accounts.py b/hyperkitty/views/accounts.py index 42edd49..43ee5c6 100644 --- a/hyperkitty/views/accounts.py +++ b/hyperkitty/views/accounts.py @@ -31,6 +31,7 @@ from django.contrib.auth.models import User from django.contrib.auth.views import login as django_login_view from django.shortcuts import render, redirect from django.utils.http import is_safe_url +from django.utils.timezone import utc #from django.utils.translation import gettext as _ from social_auth.backends import SocialAuthBackend @@ -189,7 +190,7 @@ def last_views(request): last_views = last_views_paginator.page(last_views_paginator.num_pages) for last_view in last_views: thread = store.get_thread(last_view.list_address, last_view.threadid) - if thread.date_active > last_view.view_date: + if thread.date_active.replace(tzinfo=utc) > last_view.view_date: # small optimization: only query the replies if necessary # XXX: Storm-specific (count method) thread.unread = thread.replies_after(last_view.view_date).count() diff --git a/hyperkitty/views/list.py b/hyperkitty/views/list.py index f4f75dd..8bb832e 100644 --- a/hyperkitty/views/list.py +++ b/hyperkitty/views/list.py @@ -29,6 +29,7 @@ from django.core.urlresolvers import reverse from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger from django.utils import formats from django.utils.dateformat import format as date_format +from django.utils.timezone import utc from django.http import Http404 from hyperkitty.models import Tag, Favorite, LastView @@ -139,7 +140,8 @@ def _thread_list(request, mlist, threads, template_name='thread_list.html', extr except LastView.DoesNotExist: thread.unread = True else: - if thread.date_active > last_view_obj.view_date: + if thread.date_active.replace(tzinfo=utc) \ + > last_view_obj.view_date: thread.unread = True paginator = Paginator(threads, 10) @@ -196,7 +198,7 @@ def overview(request, mlist_fqdn=None): for thread_obj in threads_result: thread = Thread(thread_obj.thread_id, thread_obj.subject, thread_obj.participants, len(thread_obj), - thread_obj.date_active) + thread_obj.date_active.replace(tzinfo=utc)) # Statistics on how many participants and threads this month participants.update(thread.participants) threads.append(thread) diff --git a/hyperkitty/views/thread.py b/hyperkitty/views/thread.py index 34fc5d9..03cfd6a 100644 --- a/hyperkitty/views/thread.py +++ b/hyperkitty/views/thread.py @@ -30,6 +30,7 @@ from django.template import RequestContext, loader from django.shortcuts import render from django.core.urlresolvers import reverse from django.core.exceptions import SuspiciousOperation +from django.utils.timezone import utc import robot_detection from hyperkitty.models import Tag, Favorite, LastView @@ -166,7 +167,7 @@ def replies(request, mlist_fqdn, threadid): last_view = request.GET.get("last_view") if last_view: try: - last_view = datetime.datetime.fromtimestamp(int(last_view)) + last_view = datetime.datetime.fromtimestamp(int(last_view), utc) except ValueError: last_view = None context = { |