2 from django.utils.translation import ugettext as _
6 friendly_name = _("comment")
9 ordering = ('-added_at',)
12 def _update_parent_comment_count(self, diff):
14 parent.comment_count = parent.comment_count + diff
19 return self._comment()
22 if settings.FORM_ALLOW_MARKDOWN_IN_COMMENTS:
23 return self.as_markdown('limitedsyntax')
29 return self.absolute_parent.headline
32 def content_object(self):
33 return self.parent.leaf
35 def save(self, *args, **kwargs):
36 super(Comment,self).save(*args, **kwargs)
39 self.parent.reset_comment_count_cache()
41 def mark_deleted(self, user):
42 if super(Comment, self).mark_deleted(user):
43 self.parent.reset_comment_count_cache()
45 def unmark_deleted(self):
46 if super(Comment, self).unmark_deleted():
47 self.parent.reset_comment_count_cache()
49 def is_reply_to(self, user):
50 inreply = re.search('@\w+', self.body)
51 if inreply is not None:
52 return user.username.startswith(inreply.group(0))
56 def get_absolute_url(self):
57 return self.abs_parent.get_absolute_url() + "#%d" % self.id
59 def __unicode__(self):