From 4c943946843750f5e4273e4e5e7a5b7530c96f3a Mon Sep 17 00:00:00 2001 From: Paul Nichols Date: Tue, 8 Apr 2014 17:05:31 -0400 Subject: [PATCH] changed timestamp to separate created and modified fields; old entries marked as read were appearing on top of the list as most recent notifications --- heythere/models.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/heythere/models.py b/heythere/models.py index 3ea505e..c9978c5 100644 --- a/heythere/models.py +++ b/heythere/models.py @@ -89,7 +89,8 @@ class Notification(models.Model): The `headline` and `body` fields should be filled in using the template keys in the chosen notification type. """ - timestamp = models.DateTimeField(auto_now=True) + created = models.DateTimeField(auto_now_add=True) + modified = models.DateTimeField(auto_now=True) sent_at = models.DateTimeField(null=True, blank=True) active = models.BooleanField(default=True) user = models.ForeignKey(django_settings.AUTH_USER_MODEL, @@ -107,10 +108,10 @@ def __init__(self, *args, **kwargs): get_notification_types, list)() class Meta: - ordering = ['-timestamp'] + ordering = ['-created'] def __unicode__(self): - return u'{0.timestamp:%Y/%m/%d %H:%M} - {0.user}'.format(self) + return u'{0.created:%Y/%m/%d %H:%M} - {0.user}'.format(self) def save(self, *args, **kwargs): if not hasattr(self.headline_dict, 'keys'):