Mercurial > public > sg101
diff gpp/weblinks/models.py @ 277:d424b8bae71d
Fixing #128 and #129. Add elsewhere weblinks to search content. Add support for haystack's get_update_field() method.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Sat, 02 Oct 2010 23:24:39 +0000 |
parents | 7e8d2dda99e3 |
children | 368d731af479 |
line wrap: on
line diff
--- a/gpp/weblinks/models.py Thu Sep 30 00:06:04 2010 +0000 +++ b/gpp/weblinks/models.py Sat Oct 02 23:24:39 2010 +0000 @@ -36,7 +36,8 @@ url = models.URLField(verify_exists=False, db_index=True) description = models.TextField(blank=True) user = models.ForeignKey(User) - date_added = models.DateField() + date_added = models.DateTimeField(db_index=True) + update_date = models.DateTimeField(db_index=True, blank=True) class Meta: abstract = True @@ -57,6 +58,16 @@ def __unicode__(self): return self.title + def save(self, *args, **kwargs): + if not self.pk: + if not self.date_added: + self.date_added = datetime.datetime.now() + self.update_date = self.date_added + else: + self.update_date = datetime.datetime.now() + + super(Link, self).save(*args, **kwargs) + @models.permalink def get_absolute_url(self): return ('weblinks-link_detail', [str(self.id)]) @@ -81,6 +92,10 @@ def save(self, *args, **kwargs): if not self.pk: self.date_added = datetime.datetime.now() + self.update_date = self.date_added + else: + self.update_date = datetime.datetime.now() + super(PendingLink, self).save(*args, **kwargs)