X-Git-Url: https://git.openstreetmap.org./osqa.git/blobdiff_plain/32c46c35fc9dbf3305dc774b144ff5af5176c9de..fe388980b431aef835eaf43f4547e51f763c3f4b:/forum/models/comment.py?ds=inline diff --git a/forum/models/comment.py b/forum/models/comment.py index a2e7425..793a1f7 100644 --- a/forum/models/comment.py +++ b/forum/models/comment.py @@ -1,7 +1,10 @@ from base import * +from django.utils.translation import ugettext as _ import re class Comment(Node): + friendly_name = _("comment") + class Meta(Node.Meta): ordering = ('-added_at',) proxy = True @@ -13,7 +16,10 @@ class Comment(Node): @property def comment(self): - return self.body + if settings.FORM_ALLOW_MARKDOWN_IN_COMMENTS: + return self.as_markdown('limitedsyntax') + else: + return self.body @property def headline(self): @@ -26,21 +32,16 @@ class Comment(Node): def save(self, *args, **kwargs): super(Comment,self).save(*args, **kwargs) - if self._is_new: - self._update_parent_comment_count(1) - - try: - ping_google() - except Exception: - logging.debug('problem pinging google did you register your sitemap with google?') + if not self.id: + self.parent.reset_comment_count_cache() def mark_deleted(self, user): if super(Comment, self).mark_deleted(user): - self._update_parent_comment_count(-1) + self.parent.reset_comment_count_cache() def unmark_deleted(self): if super(Comment, self).unmark_deleted(): - self._update_parent_comment_count(1) + self.parent.reset_comment_count_cache() def is_reply_to(self, user): inreply = re.search('@\w+', self.body) @@ -50,7 +51,7 @@ class Comment(Node): return False def get_absolute_url(self): - return self.absolute_parent.get_absolute_url() + "#%d" % self.id + return self.abs_parent.get_absolute_url() + "#%d" % self.id def __unicode__(self): return self.body