]> git.openstreetmap.org Git - osqa.git/blobdiff - forum/models/comment.py
Added the option to limit the tags creation. It will defaults to false, and there...
[osqa.git] / forum / models / comment.py
index a2e74258e036fc8dfdbb1f321680c982e5eba923..793a1f76b87dd01a4ae98fbe68682ccbb431c956 100644 (file)
@@ -1,7 +1,10 @@
 from base import *\r
+from django.utils.translation import ugettext as _\r
 import re\r
 \r
 class Comment(Node):\r
+    friendly_name = _("comment")\r
+\r
     class Meta(Node.Meta):\r
         ordering = ('-added_at',)\r
         proxy = True\r
@@ -13,7 +16,10 @@ class Comment(Node):
 \r
     @property\r
     def comment(self):\r
-        return self.body\r
+        if settings.FORM_ALLOW_MARKDOWN_IN_COMMENTS:\r
+            return self.as_markdown('limitedsyntax')\r
+        else:\r
+            return self.body\r
 \r
     @property\r
     def headline(self):\r
@@ -26,21 +32,16 @@ class Comment(Node):
     def save(self, *args, **kwargs):\r
         super(Comment,self).save(*args, **kwargs)\r
 \r
-        if self._is_new:\r
-            self._update_parent_comment_count(1)\r
-\r
-        try:\r
-            ping_google()\r
-        except Exception:\r
-            logging.debug('problem pinging google did you register your sitemap with google?')\r
+        if not self.id:\r
+            self.parent.reset_comment_count_cache()\r
 \r
     def mark_deleted(self, user):\r
         if super(Comment, self).mark_deleted(user):\r
-            self._update_parent_comment_count(-1)\r
+            self.parent.reset_comment_count_cache()\r
 \r
     def unmark_deleted(self):\r
         if super(Comment, self).unmark_deleted():\r
-            self._update_parent_comment_count(1)\r
+            self.parent.reset_comment_count_cache()\r
 \r
     def is_reply_to(self, user):\r
         inreply = re.search('@\w+', self.body)\r
@@ -50,7 +51,7 @@ class Comment(Node):
         return False\r
 \r
     def get_absolute_url(self):\r
-        return self.absolute_parent.get_absolute_url() + "#%d" % self.id\r
+        return self.abs_parent.get_absolute_url() + "#%d" % self.id\r
 \r
     def __unicode__(self):\r
         return self.body\r