131530a653fd — Peter Sanchez 11 years ago
Small version bump. Django 1.4+ support for timezones
3 files changed, 7 insertions(+), 6 deletions(-)

M callback/__init__.py
M callback/managers.py
M callback/models.py
M callback/__init__.py +1 -1
@@ 3,7 3,7 @@ from callback.base import CallbackExcept
 from callback.signals import stored_callback, processed_callback, error_callback
 
 
-__version__ = '0.5'
+__version__ = '0.6'
 __all__ = [
     'CallbackException', 'CallbackBase', 'callback_manager',
     'stored_callback', 'processed_callback', 'error_callback',

          
M callback/managers.py +2 -1
@@ 2,6 2,7 @@ import random
 import hashlib
 import datetime
 from django.db import models
+from django.utils import timezone
 from django.contrib.auth.models import User
 
 Q = models.Q

          
@@ 24,7 25,7 @@ class CallbackMapManager(models.Manager)
         return self.get_query_set().filter(query)
 
     def all_expired_callbacks(self, days=7, delete_errors=False):
-        use_date = datetime.date.today() - datetime.timedelta(days=days)
+        use_date = timezone.now().date() - datetime.timedelta(days=days)
         query = Q(is_active=False) 
         if not delete_errors:
             query &= Q(is_error=False)

          
M callback/models.py +4 -4
@@ 1,5 1,5 @@ 
-import datetime
 from django.db import models
+from django.utils import timezone
 from django.contrib.contenttypes.models import ContentType
 from django.contrib.contenttypes import generic
 from callback.managers import CallbackMapManager

          
@@ 16,8 16,8 @@ class CallbackMap(models.Model):
     is_error = models.BooleanField(default=False)
     error_msg = models.TextField(blank=True)
 
-    created_on = models.DateTimeField(default=datetime.datetime.now)
-    updated_on = models.DateTimeField(default=datetime.datetime.now)
+    created_on = models.DateTimeField(default=timezone.now)
+    updated_on = models.DateTimeField(default=timezone.now)
 
     objects = CallbackMapManager()
 

          
@@ 43,5 43,5 @@ class CallbackMap(models.Model):
 
     def save(self, *args, **kwargs):
         if self.id:
-            self.updated_on = datetime.datetime.now()
+            self.updated_on = timezone.now()
         super(CallbackMap, self).save(*args, **kwargs)