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 if settings.FORM_ALLOW_MARKDOWN_IN_COMMENTS:
20 # Avoid doing double replacement of backslashes
21 return self._as_markdown_raw(self.body,'limitedsyntax')
27 return self.absolute_parent.headline
30 def content_object(self):
31 return self.parent.leaf
33 def save(self, *args, **kwargs):
34 super(Comment,self).save(*args, **kwargs)
37 self.parent.reset_comment_count_cache()
39 def mark_deleted(self, user):
40 if super(Comment, self).mark_deleted(user):
41 self.parent.reset_comment_count_cache()
43 def unmark_deleted(self):
44 if super(Comment, self).unmark_deleted():
45 self.parent.reset_comment_count_cache()
47 def is_reply_to(self, user):
48 inreply = re.search('@\w+', self.body)
49 if inreply is not None:
50 return user.username.startswith(inreply.group(0))
54 def get_absolute_url(self):
55 return self.abs_parent.get_absolute_url() + "#%d" % self.id
57 def __unicode__(self):