From 32ce5f1266629c48fccc31c6750bc69ad6df776c Mon Sep 17 00:00:00 2001 From: Sergio Oliveira Date: Thu, 18 Jul 2013 16:16:09 -0300 Subject: [PATCH] Fixing tz issues --- src/super_archives/models.py | 4 ++-- src/super_archives/views.py | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/super_archives/models.py b/src/super_archives/models.py index 5d83088..737be03 100644 --- a/src/super_archives/models.py +++ b/src/super_archives/models.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- -import datetime from hashlib import md5 from django.db import models from django.conf import settings +from django.utils import timezone from django.contrib.auth.models import User from django.core.urlresolvers import reverse, NoReverseMatch from django.utils.translation import ugettext_lazy as _ @@ -144,7 +144,7 @@ class Thread(models.Model): # Save this pseudo now to avoid calling the # function N times in the loops below - now = datetime.datetime.now() + now = timezone.now() days_ago = lambda date: (now - date).days get_score = lambda weight, created: \ max(weight - (days_ago(created) // 3), 5) diff --git a/src/super_archives/views.py b/src/super_archives/views.py index 5aea4fa..31bd999 100644 --- a/src/super_archives/views.py +++ b/src/super_archives/views.py @@ -14,7 +14,8 @@ from .models import MailingList, Thread def thread(request, mailinglist, thread_token): try: - first_message = queries.get_first_message_in_thread(mailinglist, thread_token) + first_message = queries.get_first_message_in_thread(mailinglist, + thread_token) except ObjectDoesNotExist: raise Http404 order_by = request.GET.get('order') -- libgit2 0.21.2