From 8d2211a698afaeb189504a130e8f55eef8d10d0a Mon Sep 17 00:00:00 2001 From: Greg Price Date: Tue, 8 Jul 2014 14:48:31 -0400 Subject: [PATCH] Handle question posts from comments service --- lms/djangoapps/django_comment_client/utils.py | 17 +++++++++++------ lms/lib/comment_client/thread.py | 3 ++- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/lms/djangoapps/django_comment_client/utils.py b/lms/djangoapps/django_comment_client/utils.py index 8ec578b956..9f4065b42b 100644 --- a/lms/djangoapps/django_comment_client/utils.py +++ b/lms/djangoapps/django_comment_client/utils.py @@ -293,7 +293,11 @@ def get_annotated_content_infos(course_id, thread, user, user_info): def annotate(content): infos[str(content['id'])] = get_annotated_content_info(course_id, content, user, user_info) - for child in content.get('children', []): + for child in ( + content.get('children', []) + + content.get('endorsed_responses', []) + + content.get('non_endorsed_responses', []) + ): annotate(child) annotate(thread) return infos @@ -369,15 +373,16 @@ def safe_content(content, is_staff=False): 'at_position_list', 'children', 'highlighted_title', 'highlighted_body', 'courseware_title', 'courseware_url', 'unread_comments_count', 'read', 'group_id', 'group_name', 'group_string', 'pinned', 'abuse_flaggers', - 'stats', 'resp_skip', 'resp_limit', 'resp_total', - + 'stats', 'resp_skip', 'resp_limit', 'resp_total', 'thread_type', + 'endorsed_responses', 'non_endorsed_responses', 'non_endorsed_resp_total', ] if (content.get('anonymous') is False) and ((content.get('anonymous_to_peers') is False) or is_staff): fields += ['username', 'user_id'] - if 'children' in content: - safe_children = [safe_content(child) for child in content['children']] - content['children'] = safe_children + for child_content_key in ["children", "endorsed_responses", "non_endorsed_responses"]: + if child_content_key in content: + safe_children = [safe_content(child) for child in content[child_content_key]] + content[child_content_key] = safe_children return strip_none(extract(content, fields)) diff --git a/lms/lib/comment_client/thread.py b/lms/lib/comment_client/thread.py index 0e8d0c19b4..eb55e4224e 100644 --- a/lms/lib/comment_client/thread.py +++ b/lms/lib/comment_client/thread.py @@ -16,7 +16,8 @@ class Thread(models.Model): 'created_at', 'updated_at', 'comments_count', 'unread_comments_count', 'at_position_list', 'children', 'type', 'highlighted_title', 'highlighted_body', 'endorsed', 'read', 'group_id', 'group_name', 'pinned', - 'abuse_flaggers', 'resp_skip', 'resp_limit', 'resp_total' + 'abuse_flaggers', 'resp_skip', 'resp_limit', 'resp_total', 'thread_type', + 'endorsed_responses', 'non_endorsed_responses', 'non_endorsed_resp_total', ] updatable_fields = [