diff options
author | Evgeny Fadeev <evgeny.fadeev@gmail.com> | 2010-04-24 16:59:29 -0400 |
---|---|---|
committer | Evgeny Fadeev <evgeny.fadeev@gmail.com> | 2010-04-24 16:59:29 -0400 |
commit | 9dac785a3416e3472a69155247ad5d5af58636db (patch) | |
tree | 00bd9f66a6d1a08ecdc6271a2beec1f6c3f8516a /forum/models/base.py | |
parent | 1ca11a43c74af6c895ed330d9b115dcc335d6160 (diff) | |
download | askbot-9dac785a3416e3472a69155247ad5d5af58636db.tar.gz askbot-9dac785a3416e3472a69155247ad5d5af58636db.tar.bz2 askbot-9dac785a3416e3472a69155247ad5d5af58636db.zip |
preparing to fix fulltext search - some simple migrations
Diffstat (limited to 'forum/models/base.py')
-rwxr-xr-x | forum/models/base.py | 40 |
1 files changed, 22 insertions, 18 deletions
diff --git a/forum/models/base.py b/forum/models/base.py index 52fc8522..fcec47b4 100755 --- a/forum/models/base.py +++ b/forum/models/base.py @@ -89,30 +89,31 @@ class Content(models.Model): """ Base class for Question and Answer """ - author = models.ForeignKey(User, related_name='%(class)ss') - added_at = models.DateTimeField(default=datetime.datetime.now) + author = models.ForeignKey(User, related_name='%(class)ss') + added_at = models.DateTimeField(default=datetime.datetime.now) - wiki = models.BooleanField(default=False) - wikified_at = models.DateTimeField(null=True, blank=True) + wiki = models.BooleanField(default=False) + wikified_at = models.DateTimeField(null=True, blank=True) - locked = models.BooleanField(default=False) - locked_by = models.ForeignKey(User, null=True, blank=True, related_name='locked_%(class)ss') - locked_at = models.DateTimeField(null=True, blank=True) + locked = models.BooleanField(default=False) + locked_by = models.ForeignKey(User, null=True, blank=True, related_name='locked_%(class)ss') + locked_at = models.DateTimeField(null=True, blank=True) - score = models.IntegerField(default=0) - vote_up_count = models.IntegerField(default=0) - vote_down_count = models.IntegerField(default=0) + score = models.IntegerField(default=0) + vote_up_count = models.IntegerField(default=0) + vote_down_count = models.IntegerField(default=0) - comment_count = models.PositiveIntegerField(default=0) + comment_count = models.PositiveIntegerField(default=0) offensive_flag_count = models.SmallIntegerField(default=0) - last_edited_at = models.DateTimeField(null=True, blank=True) - last_edited_by = models.ForeignKey(User, null=True, blank=True, related_name='last_edited_%(class)ss') + last_edited_at = models.DateTimeField(null=True, blank=True) + last_edited_by = models.ForeignKey(User, null=True, blank=True, related_name='last_edited_%(class)ss') - html = models.TextField() - comments = generic.GenericRelation(Comment) - votes = generic.GenericRelation(Vote) - flagged_items = generic.GenericRelation(FlaggedItem) + html = models.TextField(null=True) + text = models.TextField(null=True) #denormalized copy of latest revision + comments = generic.GenericRelation(Comment) + votes = generic.GenericRelation(Vote) + flagged_items = generic.GenericRelation(FlaggedItem) class Meta: abstract = True @@ -141,7 +142,10 @@ class Content(models.Model): self.comment_count = self.comment_count + 1 self.save() - def post_get_last_update_info(self): + def get_latest_revision(self): + return self.revisions.all()[0] + + def post_get_last_update_info(self):#todo: rename this subroutine when = self.added_at who = self.author if self.last_edited_at and self.last_edited_at > when: |