From 5c0cafb391c2b9d2c8ba357a121bade45aa51837 Mon Sep 17 00:00:00 2001 From: Bryce Boe Date: Fri, 2 Mar 2012 18:26:59 -0800 Subject: [PATCH] Provide proper thing_id for message parents. --- r2/r2/lib/jsontemplates.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/r2/r2/lib/jsontemplates.py b/r2/r2/lib/jsontemplates.py index 0903cb954..033c1b7f4 100644 --- a/r2/r2/lib/jsontemplates.py +++ b/r2/r2/lib/jsontemplates.py @@ -402,6 +402,7 @@ class MessageJsonTemplate(ThingJsonTemplate): first_message= "first_message") def thing_attr(self, thing, attr): + from r2.models import Message if attr == "was_comment": return thing.was_comment elif attr == "context": @@ -420,6 +421,9 @@ class MessageJsonTemplate(ThingJsonTemplate): return safemarkdown(thing.body) elif attr == "author" and getattr(thing, "hide_author", False): return None + elif attr == "parent_id": + if getattr(thing, "parent_id", None): + return make_fullname(Message, thing.parent_id) return ThingJsonTemplate.thing_attr(self, thing, attr) def rendered_data(self, wrapped):