Mercurial > public > sg101
diff gpp/comments/models.py @ 294:254db4cb6a86
Changes / scripts to import forums. Other tweaks and moving other import scripts to the legacy application.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Wed, 05 Jan 2011 04:09:35 +0000 |
parents | 5c889b587416 |
children | 24f1230f3ee3 |
line wrap: on
line diff
--- a/gpp/comments/models.py Wed Dec 29 04:56:53 2010 +0000 +++ b/gpp/comments/models.py Wed Jan 05 04:09:35 2011 +0000 @@ -1,6 +1,8 @@ """ Models for the comments application. """ +import datetime + from django.db import models from django.conf import settings from django.contrib.contenttypes.models import ContentType @@ -34,9 +36,9 @@ user = models.ForeignKey(User) comment = models.TextField(max_length=COMMENT_MAX_LENGTH) html = models.TextField(blank=True) - creation_date = models.DateTimeField(auto_now_add=True) + creation_date = models.DateTimeField() ip_address = models.IPAddressField('IP Address') - is_public = models.BooleanField(default=True, + is_public = models.BooleanField(default=True, help_text='Uncheck this field to make the comment invisible.') is_removed = models.BooleanField(default=False, help_text='Check this field to replace the comment with a ' \ @@ -52,6 +54,9 @@ return u'%s: %s...' % (self.user.username, self.comment[:50]) def save(self, *args, **kwargs): + if not self.id: + self.creation_date = datetime.datetime.now() + self.html = site_markup(self.comment) super(Comment, self).save(*args, **kwargs)