From 7655e9eea05012800a034197796bd536625b45b5 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 b13c5acd4fe03dcda0212e9bb1ba5751086b474c Mon Sep 17 00:00:00 2001 From: Ibrahim Awwal Date: Tue, 28 Aug 2012 22:42:11 -0700 Subject: [PATCH 2/5] Save the user's selected sort order on the comments service. Requires cs_comments_service to have the field default_sort_key on users. --- lms/djangoapps/django_comment_client/forum/views.py | 13 ++++++++++++- lms/lib/comment_client/user.py | 4 ++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/lms/djangoapps/django_comment_client/forum/views.py b/lms/djangoapps/django_comment_client/forum/views.py index 62055f0ab7..ae8e999a8a 100644 --- a/lms/djangoapps/django_comment_client/forum/views.py +++ b/lms/djangoapps/django_comment_client/forum/views.py @@ -102,7 +102,7 @@ def get_threads(request, course_id, discussion_id=None): default_query_params = { 'page': 1, 'per_page': THREADS_PER_PAGE, - 'sort_key': 'activity', + 'sort_key': 'date', 'sort_order': 'desc', 'text': '', 'tags': '', @@ -110,6 +110,17 @@ def get_threads(request, course_id, discussion_id=None): 'course_id': course_id, } + if not request.GET.get('sort_key'): + # If the user did not select a sort key, use their last used sort key + user = cc.User.from_django_user(request.user) + user.retrieve() + default_query_params['sort_key'] = user.default_sort_key + else: + # If the user clicked a sort key, update their default sort key + user = cc.User.from_django_user(request.user) + user.default_sort_key = request.GET.get('sort_key') + user.save() + query_params = merge_dict(default_query_params, strip_none(extract(request.GET, ['page', 'sort_key', 'sort_order', 'text', 'tags']))) diff --git a/lms/lib/comment_client/user.py b/lms/lib/comment_client/user.py index ae4abf91b7..eea6fda407 100644 --- a/lms/lib/comment_client/user.py +++ b/lms/lib/comment_client/user.py @@ -8,10 +8,10 @@ class User(models.Model): accessible_fields = ['username', 'email', 'follower_ids', 'upvoted_ids', 'downvoted_ids', 'id', 'external_id', 'subscribed_user_ids', 'children', 'course_id', 'subscribed_thread_ids', 'subscribed_commentable_ids', - 'threads_count', 'comments_count', + 'threads_count', 'comments_count', 'default_sort_key' ] - updatable_fields = ['username', 'external_id', 'email'] + updatable_fields = ['username', 'external_id', 'email', 'default_sort_key'] initializable_fields = updatable_fields base_url = "{prefix}/users".format(prefix=settings.PREFIX) From cd84b63228a2954e22824ca243bb436cbca71238 Mon Sep 17 00:00:00 2001 From: Ibrahim Awwal Date: Wed, 29 Aug 2012 00:37:45 -0700 Subject: [PATCH 3/5] Make the search button line up with the search field better. --- lms/static/sass/_discussion.scss | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lms/static/sass/_discussion.scss b/lms/static/sass/_discussion.scss index 6c1988684e..51f58730fe 100644 --- a/lms/static/sass/_discussion.scss +++ b/lms/static/sass/_discussion.scss @@ -501,7 +501,8 @@ $tag-text-color: #5b614f; font-size: inherit; font-weight: bold; margin-left: 1%; - padding-top: 9px; + padding-top: 4px; + padding-bottom: 2px; text-decoration: none; } From 02e6fd17e4452b46f58713e0a0efb5cf340762db Mon Sep 17 00:00:00 2001 From: Ibrahim Awwal Date: Wed, 29 Aug 2012 22:20:20 -0700 Subject: [PATCH 4/5] Make 'date' the first sort key since it's the new default (students seem to prefer it, especially since top is kind of unclear). --- lms/templates/discussion/_sort.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lms/templates/discussion/_sort.html b/lms/templates/discussion/_sort.html index 7ba10eab7b..99ba58f7c8 100644 --- a/lms/templates/discussion/_sort.html +++ b/lms/templates/discussion/_sort.html @@ -31,9 +31,9 @@
Sort by: - ${link_to_sort('activity', 'top')} - ${link_to_sort('date', 'date')} + + ${link_to_sort('activity', 'top')} ${link_to_sort('votes', 'votes')} From e600004b1fa6280c036b67c1a932d7e6625d5595 Mon Sep 17 00:00:00 2001 From: Ibrahim Awwal Date: Fri, 31 Aug 2012 15:19:17 -0700 Subject: [PATCH 5/5] Make the comment client not explode if it doesn't get a sort preference from the comment service. --- lms/djangoapps/django_comment_client/forum/views.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lms/djangoapps/django_comment_client/forum/views.py b/lms/djangoapps/django_comment_client/forum/views.py index ae8e999a8a..2b3d140c7e 100644 --- a/lms/djangoapps/django_comment_client/forum/views.py +++ b/lms/djangoapps/django_comment_client/forum/views.py @@ -114,7 +114,8 @@ def get_threads(request, course_id, discussion_id=None): # If the user did not select a sort key, use their last used sort key user = cc.User.from_django_user(request.user) user.retrieve() - default_query_params['sort_key'] = user.default_sort_key + # TODO: After the comment service is updated this can just be user.default_sort_key because the service returns the default value + default_query_params['sort_key'] = user.get('default_sort_key') or default_query_params['sort_key'] else: # If the user clicked a sort key, update their default sort key user = cc.User.from_django_user(request.user)