From 08b233f6037940f50b26f395931549c74b2aaa78 Mon Sep 17 00:00:00 2001 From: Ibrahim Awwal Date: Tue, 28 Aug 2012 22:38:56 -0700 Subject: [PATCH 1/5] Ensure that js files are returned in alphabetical order by django-pipeline. On most systems this seems to be the default behavior, but glob2.glob's order isn't guaranteed and on my machine the order seems to be random, which causes javascript which depends on include order to fail. --- lms/envs/common.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lms/envs/common.py b/lms/envs/common.py index ce08bf9666..37d65e78f9 100644 --- a/lms/envs/common.py +++ b/lms/envs/common.py @@ -429,7 +429,7 @@ main_vendor_js = [ 'js/vendor/jquery.qtip.min.js', ] -discussion_js = glob2.glob(PROJECT_ROOT / 'static/coffee/src/discussion/*.coffee') +discussion_js = sorted(glob2.glob(PROJECT_ROOT / 'static/coffee/src/discussion/*.coffee')) # Load javascript from all of the available xmodules, and # prep it for use in pipeline js @@ -497,10 +497,10 @@ PIPELINE_JS = { 'source_filenames': [ pth.replace(COMMON_ROOT / 'static/', '') for pth - in glob2.glob(COMMON_ROOT / 'static/coffee/src/**/*.coffee') + in sorted(glob2.glob(COMMON_ROOT / 'static/coffee/src/**/*.coffee')) ] + [ pth.replace(PROJECT_ROOT / 'static/', '') - for pth in glob2.glob(PROJECT_ROOT / 'static/coffee/src/**/*.coffee')\ + for pth in sorted(glob2.glob(PROJECT_ROOT / 'static/coffee/src/**/*.coffee'))\ if pth not in courseware_only_js and pth not in discussion_js ] + [ 'js/form.ext.js', From e58af44620e495e4006938d865a8a994ff1fc0d1 Mon Sep 17 00:00:00 2001 From: Ibrahim Awwal Date: Wed, 29 Aug 2012 19:41:46 -0700 Subject: [PATCH 2/5] 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}}
From e1aa30b36f84abf55bf1bed1b9e9f3937dd8d575 Mon Sep 17 00:00:00 2001 From: Ibrahim Awwal Date: Wed, 29 Aug 2012 21:52:22 -0700 Subject: [PATCH 3/5] Style comments from moderators in light blue, and admins in light green. Also puts text after the author's name (there should be something for colorblind people, not sure what form it should take though). --- lms/static/sass/_discussion.scss | 15 +++++++++++++++ .../discussion/mustache/_content.mustache | 6 +++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/lms/static/sass/_discussion.scss b/lms/static/sass/_discussion.scss index 6c1988684e..869148a795 100644 --- a/lms/static/sass/_discussion.scss +++ b/lms/static/sass/_discussion.scss @@ -385,6 +385,14 @@ $tag-text-color: #5b614f; color: #dea03e; } } + + .author-moderator:after{ + content: " (moderator)" + } + + .author-administrator:after{ + content: " (administrator)" + } } .discussion-content { @@ -410,6 +418,13 @@ $tag-text-color: #5b614f; } } + // Role based styles + .role-moderator{ + background-color: #eafcfc; + } + .role-administrator{ + background-color: #eafcea; + } //COMMENT STYLES .comments { overflow: hidden; diff --git a/lms/templates/discussion/mustache/_content.mustache b/lms/templates/discussion/mustache/_content.mustache index 03a9211b35..f6b375dc88 100644 --- a/lms/templates/discussion/mustache/_content.mustache +++ b/lms/templates/discussion/mustache/_content.mustache @@ -1,5 +1,5 @@ -
-
+
+
{{content.votes.point}}
@@ -34,7 +34,7 @@ anonymous {{/content.anonymous}} {{^content.anonymous}} - {{content.username}} + {{content.username}} {{/content.anonymous}}
From b80ceecf87e2c9663ac9a88b1e4f420683d2c929 Mon Sep 17 00:00:00 2001 From: Ibrahim Awwal Date: Thu, 30 Aug 2012 00:19:42 -0700 Subject: [PATCH 4/5] Note when posts have been updated, and put the creation date in the title text. --- lms/djangoapps/django_comment_client/utils.py | 1 + lms/static/coffee/src/discussion/content.coffee | 3 +++ lms/templates/discussion/mustache/_content.mustache | 5 ++++- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lms/djangoapps/django_comment_client/utils.py b/lms/djangoapps/django_comment_client/utils.py index dc4a4e21e1..89d3cd99ba 100644 --- a/lms/djangoapps/django_comment_client/utils.py +++ b/lms/djangoapps/django_comment_client/utils.py @@ -222,6 +222,7 @@ def extend_content(content): 'raw_tags': ','.join(content.get('tags', [])), 'permalink': permalink(content), 'roles': roles, + 'updated': content['created_at']!=content['updated_at'], } return merge_dict(content, content_info) diff --git a/lms/static/coffee/src/discussion/content.coffee b/lms/static/coffee/src/discussion/content.coffee index 73c3688c2a..9f95c201f4 100644 --- a/lms/static/coffee/src/discussion/content.coffee +++ b/lms/static/coffee/src/discussion/content.coffee @@ -374,6 +374,9 @@ if Backbone? MathJax.Hub.Queue ["Typeset", MathJax.Hub, $contentBody.attr("id")] initTimeago: -> + @$("span.timeago").each (index, element) -> + elem = $(element) + elem.html("posted on #{$.timeago.parse(elem.html()).toLocaleString()}") @$("span.timeago").timeago() renderPartial: -> diff --git a/lms/templates/discussion/mustache/_content.mustache b/lms/templates/discussion/mustache/_content.mustache index f6b375dc88..264115919b 100644 --- a/lms/templates/discussion/mustache/_content.mustache +++ b/lms/templates/discussion/mustache/_content.mustache @@ -29,7 +29,10 @@ {{/thread}}
- sometime by + {{#content.updated}} + updated + {{/content.updated}} + {{content.created_at}} by {{#content.anonymous}} anonymous {{/content.anonymous}} From b276d8b4b11c422ec9fade45e838e98b3772fb9f Mon Sep 17 00:00:00 2001 From: David Ormsbee Date: Fri, 7 Sep 2012 09:47:13 -0400 Subject: [PATCH 5/5] Changes as per cpennington's code review --- lms/djangoapps/django_comment_client/utils.py | 2 +- lms/static/sass/_discussion.scss | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lms/djangoapps/django_comment_client/utils.py b/lms/djangoapps/django_comment_client/utils.py index 89d3cd99ba..6da7130c52 100644 --- a/lms/djangoapps/django_comment_client/utils.py +++ b/lms/djangoapps/django_comment_client/utils.py @@ -215,7 +215,7 @@ def permalink(content): 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 = 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', ''), diff --git a/lms/static/sass/_discussion.scss b/lms/static/sass/_discussion.scss index 869148a795..f19dbe36ff 100644 --- a/lms/static/sass/_discussion.scss +++ b/lms/static/sass/_discussion.scss @@ -391,7 +391,7 @@ $tag-text-color: #5b614f; } .author-administrator:after{ - content: " (administrator)" + content: " (instructor)" } }