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 return self.as_markdown('limitedsyntax')
26 return self.absolute_parent.headline
29 def content_object(self):
30 return self.parent.leaf
32 def save(self, *args, **kwargs):
33 super(Comment,self).save(*args, **kwargs)
36 self.parent.reset_comment_count_cache()
38 def mark_deleted(self, user):
39 if super(Comment, self).mark_deleted(user):
40 self.parent.reset_comment_count_cache()
42 def unmark_deleted(self):
43 if super(Comment, self).unmark_deleted():
44 self.parent.reset_comment_count_cache()
46 def is_reply_to(self, user):
47 inreply = re.search('@\w+', self.body)
48 if inreply is not None:
49 return user.username.startswith(inreply.group(0))
53 def get_absolute_url(self):
54 return self.abs_parent.get_absolute_url() + "#%d" % self.id
56 def __unicode__(self):