- def save(self, *args, **kwargs):
- super(FlaggedItem, self).save(*args, **kwargs)
- if self._is_new:
- self._update_post_flag_count(1)
-
- def cancel(self):
- if not self.canceled:
- self.canceled = True
- self.save()
- self._update_post_flag_count(-1)
-
-
-class Comment(MetaContent, UserContent, DeletableContent):
- comment = models.CharField(max_length=300)
- added_at = models.DateTimeField(default=datetime.datetime.now)
- score = models.IntegerField(default=0)
- liked_by = models.ManyToManyField(User, through='LikedComment', related_name='comments_liked')
-
- class Meta(MetaContent.Meta):
- ordering = ('-added_at',)
- db_table = u'comment'
-
- def _update_post_comment_count(self, diff):
- post = self.content_object
- post.comment_count = post.comment_count + diff
- post.save()
+ @models.permalink
+ def get_absolute_url(self):
+ return ('badge', [], {'id': self.id, 'slug': slugify(self.name)})