2 from django.utils.translation import ugettext as _
\r
6 friendly_name = _("comment")
\r
8 class Meta(Node.Meta):
\r
9 ordering = ('-added_at',)
\r
12 def _update_parent_comment_count(self, diff):
\r
13 parent = self.parent
\r
14 parent.comment_count = parent.comment_count + diff
\r
19 if settings.FORM_ALLOW_MARKDOWN_IN_COMMENTS:
\r
20 return self.as_markdown('limitedsyntax')
\r
26 return self.absolute_parent.headline
\r
29 def content_object(self):
\r
30 return self.parent.leaf
\r
32 def save(self, *args, **kwargs):
\r
33 super(Comment,self).save(*args, **kwargs)
\r
36 self.parent.reset_comment_count_cache()
\r
38 def mark_deleted(self, user):
\r
39 if super(Comment, self).mark_deleted(user):
\r
40 self.parent.reset_comment_count_cache()
\r
42 def unmark_deleted(self):
\r
43 if super(Comment, self).unmark_deleted():
\r
44 self.parent.reset_comment_count_cache()
\r
46 def is_reply_to(self, user):
\r
47 inreply = re.search('@\w+', self.body)
\r
48 if inreply is not None:
\r
49 return user.username.startswith(inreply.group(0))
\r
53 def get_absolute_url(self):
\r
54 return self.absolute_parent.get_absolute_url() + "#%d" % self.id
\r
56 def __unicode__(self):
\r