From 6211d82f7a5a30dcbb865a726d047c01f791c879 Mon Sep 17 00:00:00 2001 From: Chad Birch Date: Wed, 8 May 2013 23:39:41 -0600 Subject: [PATCH] Use correct fullname prefixes for message parents Previously, all parent_id values would be prefixed with t4_ (message), even if the message was from a comment, which would actually have either a comment or link parent. --- r2/r2/lib/jsontemplates.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/r2/r2/lib/jsontemplates.py b/r2/r2/lib/jsontemplates.py index bdda3b34a..76d2f07c8 100755 --- a/r2/r2/lib/jsontemplates.py +++ b/r2/r2/lib/jsontemplates.py @@ -469,7 +469,7 @@ class MessageJsonTemplate(ThingJsonTemplate): first_message_name = "first_message_name") def thing_attr(self, thing, attr): - from r2.models import Message + from r2.models import Comment, Link, Message if attr == "was_comment": return thing.was_comment elif attr == "context": @@ -489,7 +489,12 @@ class MessageJsonTemplate(ThingJsonTemplate): elif attr == "author" and getattr(thing, "hide_author", False): return None elif attr == "parent_id": - if getattr(thing, "parent_id", None): + if thing.was_comment: + if getattr(thing, "parent_id", None): + return make_fullname(Comment, thing.parent_id) + else: + return make_fullname(Link, thing.link_id) + elif getattr(thing, "parent_id", None): return make_fullname(Message, thing.parent_id) elif attr == "first_message_name": if getattr(thing, "first_message", None):