From fd6e30abfce344835fe5894ea08df103af708609 Mon Sep 17 00:00:00 2001 From: Ibrahim Awwal Date: Tue, 11 Sep 2012 01:33:26 -0700 Subject: [PATCH] Don't try to retrieve roles for anonymous posts. --- lms/djangoapps/django_comment_client/utils.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lms/djangoapps/django_comment_client/utils.py b/lms/djangoapps/django_comment_client/utils.py index 7b5a0bfd6f..a7f303abf4 100644 --- a/lms/djangoapps/django_comment_client/utils.py +++ b/lms/djangoapps/django_comment_client/utils.py @@ -241,8 +241,10 @@ def permalink(content): args=[content['course_id'], content['commentable_id'], content['thread_id']]) + '#' + content['id'] def extend_content(content): - user = User.objects.get(pk=content['user_id']) - roles = dict(('name', role.name.lower()) for role in user.roles.filter(course_id=content['course_id'])) + roles = {} + if content.get('user_id'): + user = User.objects.get(pk=content['user_id']) + roles = dict(('name', role.name.lower()) for role in user.roles.filter(course_id=content['course_id'])) content_info = { 'displayed_title': content.get('highlighted_title') or content.get('title', ''), 'displayed_body': content.get('highlighted_body') or content.get('body', ''), @@ -255,7 +257,7 @@ def extend_content(content): def get_courseware_context(content, course): id_map = get_discussion_id_map(course) - id = content['commentable_id'] + id = content['commentable_id'] content_info = None if id in id_map: location = id_map[id]["location"].url()