]> git.openstreetmap.org Git - osqa.git/commitdiff
added comment headline property
authorhernani <hernani@0cfe37f9-358a-4d5e-be75-b63607b5c754>
Sat, 17 Apr 2010 01:28:20 +0000 (01:28 +0000)
committerhernani <hernani@0cfe37f9-358a-4d5e-be75-b63607b5c754>
Sat, 17 Apr 2010 01:28:20 +0000 (01:28 +0000)
git-svn-id: http://svn.osqa.net/svnroot/osqa/trunk@45 0cfe37f9-358a-4d5e-be75-b63607b5c754

forum/models/comment.py
forum/templatetags/user_tags.py

index 2bf2824906f2370aa14eded1799b29ae23ecefc1..15049b2d211d733841b3160d19600d4042a84e6e 100644 (file)
@@ -15,6 +15,10 @@ class Comment(Node):
     def comment(self):\r
         return self.body\r
 \r
+    @property\r
+    def headline(self):\r
+        return self.absolute_parent.headline\r
+\r
     @property\r
     def content_object(self):\r
         return self.parent.leaf\r
index 0e9ae27abba45387bffd87a5aad79c6ae9d367c5..cf35a2e0aff685e321544daa25ed84ee30f5dd57 100644 (file)
@@ -34,29 +34,32 @@ class ActivityNode(template.Node):
         self.activity = template.Variable(activity)\r
 \r
     def render(self, context):\r
-        activity = self.activity.resolve(context)\r
-\r
-        context = {\r
-            'active_at': activity.active_at,\r
-            'description': activity.type_as_string,\r
-            'type': activity.activity_type,\r
-        }\r
-\r
-        if activity.activity_type == const.TYPE_ACTIVITY_PRIZE:\r
-            context['badge'] = True\r
-            context['title'] = activity.content_object.badge.name\r
-            context['url'] = activity.content_object.badge.get_absolute_url()\r
-            context['badge_type'] = activity.content_object.badge.type\r
-        else:\r
-            context['title'] = activity.node.headline\r
-            context['url'] = activity.node.get_absolute_url()\r
-\r
-        if activity.activity_type in (const.TYPE_ACTIVITY_UPDATE_ANSWER, const.TYPE_ACTIVITY_UPDATE_QUESTION):\r
-            context['revision'] = True\r
-            context['summary'] = activity.content_object.summary or \\r
-                    _('Revision n. %(rev_number)d') % {'rev_number': activity.content_object.revision}\r
-\r
-        return self.template.render(template.Context(context))\r
+        try:\r
+            activity = self.activity.resolve(context)\r
+\r
+            context = {\r
+                'active_at': activity.active_at,\r
+                'description': activity.type_as_string,\r
+                'type': activity.activity_type,\r
+            }\r
+\r
+            if activity.activity_type == const.TYPE_ACTIVITY_PRIZE:\r
+                context['badge'] = True\r
+                context['title'] = activity.content_object.badge.name\r
+                context['url'] = activity.content_object.badge.get_absolute_url()\r
+                context['badge_type'] = activity.content_object.badge.type\r
+            else:\r
+                context['title'] = activity.node.headline\r
+                context['url'] = activity.node.get_absolute_url()\r
+\r
+            if activity.activity_type in (const.TYPE_ACTIVITY_UPDATE_ANSWER, const.TYPE_ACTIVITY_UPDATE_QUESTION):\r
+                context['revision'] = True\r
+                context['summary'] = activity.content_object.summary or \\r
+                        _('Revision n. %(rev_number)d') % {'rev_number': activity.content_object.revision}\r
+\r
+            return self.template.render(template.Context(context))\r
+        except Exception, e:\r
+            return ''\r
 \r
 @register.tag\r
 def activity_item(parser, token):\r