diff options
author | Dan McGee <dan@archlinux.org> | 2011-04-07 15:39:53 -0500 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2011-04-07 17:03:00 -0500 |
commit | 01db07bad844e17e084f650b6732647f77a91c5c (patch) | |
tree | 3260bae1697f2aaac5140f20ea9d0e30953a5be7 /main | |
parent | 7d08d59280dc4ddbe43f277e177bce683dd51188 (diff) |
Use UTC datetime objects everywhere
Rather than the twisted mix of local times and UTC times we currently have.
Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'main')
-rw-r--r-- | main/models.py | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/main/models.py b/main/models.py index 4370fa24..8d34731f 100644 --- a/main/models.py +++ b/main/models.py @@ -5,6 +5,7 @@ from django.contrib.sites.models import Site from main.utils import cache_function, make_choice from packages.models import PackageRelation +from datetime import datetime from itertools import groupby import pytz @@ -351,7 +352,7 @@ class Todolist(models.Model): creator = models.ForeignKey(User) name = models.CharField(max_length=255) description = models.TextField() - date_added = models.DateTimeField(auto_now_add=True, db_index=True) + date_added = models.DateTimeField(db_index=True) objects = TodolistManager() def __unicode__(self): @@ -383,10 +384,18 @@ class TodolistPkg(models.Model): db_table = 'todolist_pkgs' unique_together = (('list','pkg'),) +def set_todolist_fields(sender, **kwargs): + todolist = kwargs['instance'] + if not todolist.date_added: + todolist.date_added = datetime.utcnow() + # connect signals needed to keep cache in line with reality from main.utils import refresh_package_latest -from django.db.models.signals import post_save +from django.db.models.signals import pre_save, post_save + post_save.connect(refresh_package_latest, sender=Package, dispatch_uid="main.models") +pre_save.connect(set_todolist_fields, sender=Todolist, + dispatch_uid="main.models") # vim: set ts=4 sw=4 et: |