diff --git a/lms/djangoapps/django_comment_client/forum/views.py b/lms/djangoapps/django_comment_client/forum/views.py index 5f94eade77..58b6d30182 100644 --- a/lms/djangoapps/django_comment_client/forum/views.py +++ b/lms/djangoapps/django_comment_client/forum/views.py @@ -112,7 +112,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': '', @@ -120,6 +120,18 @@ 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() + # 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) + 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/envs/common.py b/lms/envs/common.py index 5cd28d24d9..5c8a8bf3d6 100644 --- a/lms/envs/common.py +++ b/lms/envs/common.py @@ -432,7 +432,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 @@ -500,10 +500,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', 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) diff --git a/lms/static/sass/_discussion.scss b/lms/static/sass/_discussion.scss index 755ef91289..b00dc069f1 100644 --- a/lms/static/sass/_discussion.scss +++ b/lms/static/sass/_discussion.scss @@ -506,7 +506,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; } 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 @@