From e58af44620e495e4006938d865a8a994ff1fc0d1 Mon Sep 17 00:00:00 2001 From: Ibrahim Awwal Date: Wed, 29 Aug 2012 19:41:46 -0700 Subject: [PATCH] Annotate comment content wrappers with classes for the roles of the author. --- lms/djangoapps/django_comment_client/utils.py | 5 +++++ lms/templates/discussion/mustache/_content.mustache | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lms/djangoapps/django_comment_client/utils.py b/lms/djangoapps/django_comment_client/utils.py index 516344d79b..dc4a4e21e1 100644 --- a/lms/djangoapps/django_comment_client/utils.py +++ b/lms/djangoapps/django_comment_client/utils.py @@ -8,7 +8,9 @@ from django.utils import simplejson from django.db import connection from django.conf import settings from django.core.urlresolvers import reverse +from django.contrib.auth.models import User from django_comment_client.permissions import check_permissions_by_view +from django_comment_client.models import Role from mitxmako import middleware import logging @@ -212,11 +214,14 @@ 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'])]) content_info = { 'displayed_title': content.get('highlighted_title') or content.get('title', ''), 'displayed_body': content.get('highlighted_body') or content.get('body', ''), 'raw_tags': ','.join(content.get('tags', [])), 'permalink': permalink(content), + 'roles': roles, } return merge_dict(content, content_info) diff --git a/lms/templates/discussion/mustache/_content.mustache b/lms/templates/discussion/mustache/_content.mustache index b4f3176931..03a9211b35 100644 --- a/lms/templates/discussion/mustache/_content.mustache +++ b/lms/templates/discussion/mustache/_content.mustache @@ -1,5 +1,5 @@
-
+
{{content.votes.point}}