From 2b23c403450b703842c6cca630a613ba89938722 Mon Sep 17 00:00:00 2001 From: marco Date: Thu, 17 Jan 2013 15:25:35 -0500 Subject: [PATCH 01/18] minor tweaks to dropdown text and addition of dropdown menu (without data links) for intructor visilibility dropdown in main discussion forum; --- lms/static/sass/_discussion.scss | 22 ++++++++++++++++++- .../discussion/_filter_dropdown.html | 2 +- lms/templates/discussion/_new_post.html | 2 +- lms/templates/discussion/_single_thread.html | 1 + .../discussion/_thread_list_template.html | 9 +++++++- 5 files changed, 32 insertions(+), 4 deletions(-) diff --git a/lms/static/sass/_discussion.scss b/lms/static/sass/_discussion.scss index 809c968fe6..9148421e4c 100644 --- a/lms/static/sass/_discussion.scss +++ b/lms/static/sass/_discussion.scss @@ -181,7 +181,7 @@ body.discussion { .drop-arrow { float: right; color: #999; - line-height: 36px; + line-height: 37px; } } @@ -1020,6 +1020,18 @@ body.discussion { } } + .group-filter-label { + width: 40px; + margin-left:10px; + } + + .group-filter-select { + margin: 5px 0px 5px 5px; + width: 80px; + font-size:10px; + background: transparent; + border-color: #ccc; + } } .post-list-wrapper { @@ -1327,6 +1339,8 @@ body.discussion { margin-left: 40px; } + + .post-tools { @include clearfix; margin-top: 15px; @@ -1357,6 +1371,12 @@ body.discussion { margin-bottom: 20px; } + .group-visibility-label { + font-size: 12px; + color:#ddd; + font-style: italic; + } + .responses { list-style: none; margin-top: 40px; diff --git a/lms/templates/discussion/_filter_dropdown.html b/lms/templates/discussion/_filter_dropdown.html index 484ee05101..8272fdd062 100644 --- a/lms/templates/discussion/_filter_dropdown.html +++ b/lms/templates/discussion/_filter_dropdown.html @@ -30,7 +30,7 @@ + Show: + +
diff --git a/lms/templates/discussion/_thread_list_template.html b/lms/templates/discussion/_thread_list_template.html index 48aef4debf..31943ef8ad 100644 --- a/lms/templates/discussion/_thread_list_template.html +++ b/lms/templates/discussion/_thread_list_template.html @@ -24,7 +24,6 @@ -
From 5bfd2c33b0ce96066a5b26befe57a7666e7776d0 Mon Sep 17 00:00:00 2001 From: Your Name Date: Tue, 29 Jan 2013 17:34:52 -0500 Subject: [PATCH 04/18] send cohort to post view context --- lms/djangoapps/django_comment_client/forum/views.py | 3 ++- lms/templates/discussion/_new_post.html | 8 +++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lms/djangoapps/django_comment_client/forum/views.py b/lms/djangoapps/django_comment_client/forum/views.py index 29000a225f..9737d59537 100644 --- a/lms/djangoapps/django_comment_client/forum/views.py +++ b/lms/djangoapps/django_comment_client/forum/views.py @@ -11,7 +11,7 @@ from django.contrib.auth.models import User from mitxmako.shortcuts import render_to_response, render_to_string from courseware.courses import get_course_with_access -from course_groups.cohorts import get_cohort_id +from course_groups.cohorts import get_cohort_id, get_course_cohorts from courseware.access import has_access from urllib import urlencode @@ -166,6 +166,7 @@ def forum_form_discussion(request, course_id): 'category_map': category_map, 'roles': saxutils.escape(json.dumps(utils.get_role_ids(course_id)), escapedict), 'is_moderator': cached_has_permission(request.user, "see_all_cohorts", course_id), + 'cohorts': get_course_cohorts } # print "start rendering.." return render_to_response('discussion/index.html', context) diff --git a/lms/templates/discussion/_new_post.html b/lms/templates/discussion/_new_post.html index 26c886c6ac..c733704d09 100644 --- a/lms/templates/discussion/_new_post.html +++ b/lms/templates/discussion/_new_post.html @@ -45,13 +45,15 @@ %elif course.metadata.get("allow_anonymous_to_peers", False): %endif - % if true: + % if is_moderator:
Make visible to:
%endif From 1fc26de945e97b736e4e837b8ada57a5ba661114 Mon Sep 17 00:00:00 2001 From: Your Name Date: Wed, 30 Jan 2013 15:19:43 -0500 Subject: [PATCH 05/18] merge master --- common/djangoapps/course_groups/cohorts.py | 3 ++- lms/djangoapps/django_comment_client/forum/views.py | 9 +++++++-- lms/templates/discussion/_new_post.html | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/common/djangoapps/course_groups/cohorts.py b/common/djangoapps/course_groups/cohorts.py index f84e18b214..5c8a1ca067 100644 --- a/common/djangoapps/course_groups/cohorts.py +++ b/common/djangoapps/course_groups/cohorts.py @@ -21,7 +21,8 @@ def is_course_cohorted(course_id): Raises: Http404 if the course doesn't exist. """ - return courses.get_course_by_id(course_id).is_cohorted + #return courses.get_course_by_id(course_id).is_cohorted + return True def get_cohort_id(user, course_id): diff --git a/lms/djangoapps/django_comment_client/forum/views.py b/lms/djangoapps/django_comment_client/forum/views.py index 9737d59537..715cb575d4 100644 --- a/lms/djangoapps/django_comment_client/forum/views.py +++ b/lms/djangoapps/django_comment_client/forum/views.py @@ -117,6 +117,8 @@ def forum_form_discussion(request, course_id): Renders the main Discussion page, potentially filtered by a search query """ course = get_course_with_access(request.user, course_id, 'load') + print "\n\n\n\n\n****************************" + print course category_map = utils.get_discussion_category_map(course) try: @@ -165,10 +167,13 @@ def forum_form_discussion(request, course_id): 'course_id': course.id, 'category_map': category_map, 'roles': saxutils.escape(json.dumps(utils.get_role_ids(course_id)), escapedict), - 'is_moderator': cached_has_permission(request.user, "see_all_cohorts", course_id), - 'cohorts': get_course_cohorts + #'is_moderator': cached_has_permission(request.user, "see_all_cohorts", course_id), + 'is_moderator': True, + 'cohorts': get_course_cohorts(course_id) } # print "start rendering.." + print "\n\n\n\n\n\n*************************************" + print context return render_to_response('discussion/index.html', context) @login_required diff --git a/lms/templates/discussion/_new_post.html b/lms/templates/discussion/_new_post.html index c733704d09..3af63f9ea1 100644 --- a/lms/templates/discussion/_new_post.html +++ b/lms/templates/discussion/_new_post.html @@ -45,7 +45,7 @@ %elif course.metadata.get("allow_anonymous_to_peers", False): %endif - % if is_moderator: + %if is_moderator:
Make visible to: %endif - %if is_moderator: -
+ %if is_course_cohorted: +
Make visible to: - - %for c in cohorts: - - %endfor + %if is_moderator: + %for c in cohorts: + + %endfor + %else: + + %endif
From c25cd33214c8232250bd823121e7c53d408c4595 Mon Sep 17 00:00:00 2001 From: Your Name Date: Thu, 31 Jan 2013 17:22:54 -0500 Subject: [PATCH 07/18] remove print --- lms/djangoapps/django_comment_client/forum/views.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/lms/djangoapps/django_comment_client/forum/views.py b/lms/djangoapps/django_comment_client/forum/views.py index b5c65202d9..64ba703d55 100644 --- a/lms/djangoapps/django_comment_client/forum/views.py +++ b/lms/djangoapps/django_comment_client/forum/views.py @@ -117,8 +117,6 @@ def forum_form_discussion(request, course_id): Renders the main Discussion page, potentially filtered by a search query """ course = get_course_with_access(request.user, course_id, 'load') - print "\n\n\n\n\n****************************" - print course category_map = utils.get_discussion_category_map(course) try: From f2f745965655e1d19c853fded737d4c8cb6b3064 Mon Sep 17 00:00:00 2001 From: Your Name Date: Thu, 31 Jan 2013 17:24:08 -0500 Subject: [PATCH 08/18] remove more prints --- lms/djangoapps/django_comment_client/base/views.py | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/lms/djangoapps/django_comment_client/base/views.py b/lms/djangoapps/django_comment_client/base/views.py index 6e86e629a1..7f0809cabb 100644 --- a/lms/djangoapps/django_comment_client/base/views.py +++ b/lms/djangoapps/django_comment_client/base/views.py @@ -94,26 +94,16 @@ def create_thread(request, course_id, commentable_id): # Cohort the thread if the commentable is cohorted. if is_commentable_cohorted(course_id, commentable_id): - print "********************** IS COHORTED" user_group_id = get_cohort_id(user, course_id) - print "********************** USER GOUP ID IS" - print user_group_id # TODO (vshnayder): once we have more than just cohorts, we'll want to # change this to a single get_group_for_user_and_commentable function # that can do different things depending on the commentable_id if cached_has_permission(request.user, "see_all_cohorts", course_id) or True: # admins can optionally choose what group to post as - - print "********************** CACHED HAS PERMISSIONS TRUE" group_id = post.get('group_id', user_group_id) else: # regular users always post with their own id. - print "********************** CACHED HAS PERMISSIONS FALSE" group_id = user_group_id - print "\n\n\n\n\n********************************* group is " - print group_id - print "\n\n\n\n\n********************************* and post is" - print post thread.update_attributes(group_id=group_id) thread.save() From da1660a043fcf6e28769fd3a9b8c26f55fdd98d2 Mon Sep 17 00:00:00 2001 From: Your Name Date: Thu, 31 Jan 2013 17:34:37 -0500 Subject: [PATCH 09/18] fix get_cohorted_commentables --- common/djangoapps/course_groups/cohorts.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/djangoapps/course_groups/cohorts.py b/common/djangoapps/course_groups/cohorts.py index 4fda68bf36..4d74f70b26 100644 --- a/common/djangoapps/course_groups/cohorts.py +++ b/common/djangoapps/course_groups/cohorts.py @@ -79,7 +79,7 @@ def get_cohorted_commentables(course_id): # this is the easy case :) ans = [] else: - ans = course.top_level_discussion_topic_ids + ans = course.cohorted_discussions return ans From 8fd32ed5026f9fb4fd287958acef933373c2797e Mon Sep 17 00:00:00 2001 From: Your Name Date: Fri, 1 Feb 2013 13:01:54 -0500 Subject: [PATCH 10/18] update to show cohort name on create and cohort name on view all threads, added cohort dictionary to convert ids to names --- common/djangoapps/course_groups/cohorts.py | 6 +----- lms/djangoapps/django_comment_client/base/views.py | 2 +- .../django_comment_client/forum/views.py | 11 +++++++++-- lms/static/sass/_discussion.scss | 14 +++++++++----- lms/templates/discussion/_new_post.html | 4 ++-- lms/templates/discussion/_single_thread.html | 5 ++++- .../discussion/_underscore_templates.html | 4 +++- 7 files changed, 29 insertions(+), 17 deletions(-) diff --git a/common/djangoapps/course_groups/cohorts.py b/common/djangoapps/course_groups/cohorts.py index 4d74f70b26..6bb4ad7413 100644 --- a/common/djangoapps/course_groups/cohorts.py +++ b/common/djangoapps/course_groups/cohorts.py @@ -21,8 +21,7 @@ def is_course_cohorted(course_id): Raises: Http404 if the course doesn't exist. """ - #return courses.get_course_by_id(course_id).is_cohorted - return True + return courses.get_course_by_id(course_id).is_cohorted def get_cohort_id(user, course_id): @@ -30,9 +29,6 @@ def get_cohort_id(user, course_id): Given a course id and a user, return the id of the cohort that user is assigned to in that course. If they don't have a cohort, return None. """ - print "\n\n\n\n\n*********************************" - print user - print course_id cohort = get_cohort(user, course_id) return None if cohort is None else cohort.id diff --git a/lms/djangoapps/django_comment_client/base/views.py b/lms/djangoapps/django_comment_client/base/views.py index 7f0809cabb..ce53a8efbb 100644 --- a/lms/djangoapps/django_comment_client/base/views.py +++ b/lms/djangoapps/django_comment_client/base/views.py @@ -98,7 +98,7 @@ def create_thread(request, course_id, commentable_id): # TODO (vshnayder): once we have more than just cohorts, we'll want to # change this to a single get_group_for_user_and_commentable function # that can do different things depending on the commentable_id - if cached_has_permission(request.user, "see_all_cohorts", course_id) or True: + if cached_has_permission(request.user, "see_all_cohorts", course_id): # admins can optionally choose what group to post as group_id = post.get('group_id', user_group_id) else: diff --git a/lms/djangoapps/django_comment_client/forum/views.py b/lms/djangoapps/django_comment_client/forum/views.py index 64ba703d55..c92324cbbb 100644 --- a/lms/djangoapps/django_comment_client/forum/views.py +++ b/lms/djangoapps/django_comment_client/forum/views.py @@ -152,6 +152,10 @@ def forum_form_discussion(request, course_id): #trending_tags = cc.search_trending_tags( # course_id, #) + cohorts = get_course_cohorts(course_id) + cohort_dictionary = dict() + for c in cohorts: + cohort_dictionary[c.id] = c.name context = { 'csrf': csrf(request)['csrf_token'], @@ -167,12 +171,15 @@ def forum_form_discussion(request, course_id): 'category_map': category_map, 'roles': saxutils.escape(json.dumps(utils.get_role_ids(course_id)), escapedict), 'is_moderator': cached_has_permission(request.user, "see_all_cohorts", course_id), - 'cohorts': get_course_cohorts(course_id), - 'cohort': get_cohort_id(user, course_id), + 'cohorts': cohorts, + 'cohort_map': cohort_dictionary, + 'user_cohort': get_cohort_id(user, course_id), 'cohorted_commentables': get_cohorted_commentables(course_id), 'is_course_cohorted': is_course_cohorted(course_id) } # print "start rendering.." + print "\n\n\n\n*******************************" + print context return render_to_response('discussion/index.html', context) @login_required diff --git a/lms/static/sass/_discussion.scss b/lms/static/sass/_discussion.scss index 2d7e5a8354..a914751280 100644 --- a/lms/static/sass/_discussion.scss +++ b/lms/static/sass/_discussion.scss @@ -1377,11 +1377,7 @@ body.discussion { margin-bottom: 20px; } - .group-visibility-label { - font-size: 12px; - color:#fff; - font-style: italic; - } + .responses { list-style: none; @@ -2438,3 +2434,11 @@ body.discussion { .discussion-user-threads { @extend .discussion-module } + + +.group-visibility-label { + font-size: 12px; + color:#000; + font-style: italic; + background-color:#fff; + } \ No newline at end of file diff --git a/lms/templates/discussion/_new_post.html b/lms/templates/discussion/_new_post.html index 1bc6148dbe..5b55d409df 100644 --- a/lms/templates/discussion/_new_post.html +++ b/lms/templates/discussion/_new_post.html @@ -55,10 +55,10 @@ %if is_moderator: %for c in cohorts: - + %endfor %else: - + %endif diff --git a/lms/templates/discussion/_single_thread.html b/lms/templates/discussion/_single_thread.html index 7f9dc84564..d4115668a8 100644 --- a/lms/templates/discussion/_single_thread.html +++ b/lms/templates/discussion/_single_thread.html @@ -5,7 +5,10 @@
-
This post visible only to group 1.
+ %if thread['group_id'] +
This post visible only to group ${cohort_dictionary[thread['group_id']]}.
+ %endif + + ${thread['votes']['up_count']}

${thread['title']}

diff --git a/lms/templates/discussion/_underscore_templates.html b/lms/templates/discussion/_underscore_templates.html index 105d677aba..be6e9a5a07 100644 --- a/lms/templates/discussion/_underscore_templates.html +++ b/lms/templates/discussion/_underscore_templates.html @@ -26,7 +26,9 @@

-
This post visible only to Group 1.
+ %if thread['group_id'] +
This post visible only to Group ${cohort_dictionary[thread['group_id']]}.
+ %endif + ${'<%- votes["up_count"] %>'}

${'<%- title %>'}

From fcbd4bd1cd5ed1b83cd000f3f58fa4d45beeddcc Mon Sep 17 00:00:00 2001 From: Kevin Chugh Date: Sat, 2 Feb 2013 05:46:11 -0500 Subject: [PATCH 11/18] produce and consume group_id from dropdowns --- .../django_comment_client/base/views.py | 23 +++++++++++-------- .../django_comment_client/forum/views.py | 2 -- lms/djangoapps/django_comment_client/utils.py | 2 +- lms/templates/discussion/_new_post.html | 2 +- .../discussion/_underscore_templates.html | 2 +- 5 files changed, 17 insertions(+), 14 deletions(-) diff --git a/lms/djangoapps/django_comment_client/base/views.py b/lms/djangoapps/django_comment_client/base/views.py index ce53a8efbb..604fe60282 100644 --- a/lms/djangoapps/django_comment_client/base/views.py +++ b/lms/djangoapps/django_comment_client/base/views.py @@ -86,27 +86,32 @@ def create_thread(request, course_id, commentable_id): 'anonymous_to_peers' : anonymous_to_peers, 'commentable_id' : commentable_id, 'course_id' : course_id, - 'user_id' : request.user.id, + 'user_id' : request.user.id }) user = cc.User.from_django_user(request.user) + #kevinchugh because the new requirement is that all groups will be determined + #by the group id in the request this all goes away + # Cohort the thread if the commentable is cohorted. - if is_commentable_cohorted(course_id, commentable_id): - user_group_id = get_cohort_id(user, course_id) + #if is_commentable_cohorted(course_id, commentable_id): + # user_group_id = get_cohort_id(user, course_id) # TODO (vshnayder): once we have more than just cohorts, we'll want to # change this to a single get_group_for_user_and_commentable function # that can do different things depending on the commentable_id - if cached_has_permission(request.user, "see_all_cohorts", course_id): + # if cached_has_permission(request.user, "see_all_cohorts", course_id): # admins can optionally choose what group to post as - group_id = post.get('group_id', user_group_id) - else: + # group_id = post.get('group_id', user_group_id) + # else: # regular users always post with their own id. - group_id = user_group_id - thread.update_attributes(group_id=group_id) - + # group_id = user_group_id + if post['group_id']: + thread.update_attributes(group_id=post['group_id']) + thread.save() + print thread if post.get('auto_subscribe', 'false').lower() == 'true': user = cc.User.from_django_user(request.user) user.follow(thread) diff --git a/lms/djangoapps/django_comment_client/forum/views.py b/lms/djangoapps/django_comment_client/forum/views.py index c92324cbbb..fa07394c90 100644 --- a/lms/djangoapps/django_comment_client/forum/views.py +++ b/lms/djangoapps/django_comment_client/forum/views.py @@ -178,8 +178,6 @@ def forum_form_discussion(request, course_id): 'is_course_cohorted': is_course_cohorted(course_id) } # print "start rendering.." - print "\n\n\n\n*******************************" - print context return render_to_response('discussion/index.html', context) @login_required diff --git a/lms/djangoapps/django_comment_client/utils.py b/lms/djangoapps/django_comment_client/utils.py index 3c9669ac37..07d8ef9660 100644 --- a/lms/djangoapps/django_comment_client/utils.py +++ b/lms/djangoapps/django_comment_client/utils.py @@ -374,7 +374,7 @@ def safe_content(content): 'updated_at', 'depth', 'type', 'commentable_id', 'comments_count', 'at_position_list', 'children', 'highlighted_title', 'highlighted_body', 'courseware_title', 'courseware_url', 'tags', 'unread_comments_count', - 'read', + 'read', 'group_id' ] if (content.get('anonymous') is False) and (content.get('anonymous_to_peers') is False): diff --git a/lms/templates/discussion/_new_post.html b/lms/templates/discussion/_new_post.html index 5b55d409df..a009f19350 100644 --- a/lms/templates/discussion/_new_post.html +++ b/lms/templates/discussion/_new_post.html @@ -52,7 +52,7 @@

Make visible to: diff --git a/lms/templates/discussion/_single_thread.html b/lms/templates/discussion/_single_thread.html index d4115668a8..0dec32ad47 100644 --- a/lms/templates/discussion/_single_thread.html +++ b/lms/templates/discussion/_single_thread.html @@ -4,6 +4,7 @@
+
%if thread['group_id']
This post visible only to group ${cohort_dictionary[thread['group_id']]}.
diff --git a/lms/templates/discussion/_underscore_templates.html b/lms/templates/discussion/_underscore_templates.html index 08c1890f7f..9182323568 100644 --- a/lms/templates/discussion/_underscore_templates.html +++ b/lms/templates/discussion/_underscore_templates.html @@ -28,7 +28,7 @@
${"<% if (obj.group_id) { %>"} -
This post visible only to Group ${"<%- obj.group_name%>"}.
+
${"<%- obj.group_string%>"}.
${"<% } %>"} + ${'<%- votes["up_count"] %>'} diff --git a/lms/templates/discussion/mustache/_content.mustache b/lms/templates/discussion/mustache/_content.mustache index 8f2ebca2a9..6bcf048915 100644 --- a/lms/templates/discussion/mustache/_content.mustache +++ b/lms/templates/discussion/mustache/_content.mustache @@ -1,4 +1,5 @@
+CONTENT MUSTACHE
diff --git a/lms/templates/discussion/mustache/_inline_discussion.mustache b/lms/templates/discussion/mustache/_inline_discussion.mustache index 0140a6221a..c9252bd9f3 100644 --- a/lms/templates/discussion/mustache/_inline_discussion.mustache +++ b/lms/templates/discussion/mustache/_inline_discussion.mustache @@ -1,6 +1,4 @@
- -
@@ -36,6 +34,7 @@
{{#threads}} +
{{group_string}}
{{/threads}} From c7a133470d42bf9aa11d682a729450ffbe233231 Mon Sep 17 00:00:00 2001 From: Kevin Chugh Date: Tue, 5 Feb 2013 22:43:09 -0500 Subject: [PATCH 17/18] inline discussions working --- .../discussion/discussion_module_view.coffee | 9 ++++--- .../discussion_thread_view_inline.coffee | 5 +++- .../django_comment_client/forum/views.py | 24 ++++++++++++++----- .../mustache/_inline_discussion.mustache | 1 - .../mustache/_inline_thread.mustache | 1 - .../mustache/_inline_thread_cohorted.mustache | 22 +++++++++++++++++ 6 files changed, 48 insertions(+), 14 deletions(-) create mode 100644 lms/templates/discussion/mustache/_inline_thread_cohorted.mustache diff --git a/common/static/coffee/src/discussion/discussion_module_view.coffee b/common/static/coffee/src/discussion/discussion_module_view.coffee index 6fce4c66cb..077210bc4f 100644 --- a/common/static/coffee/src/discussion/discussion_module_view.coffee +++ b/common/static/coffee/src/discussion/discussion_module_view.coffee @@ -74,13 +74,12 @@ if Backbone? @discussion = new Discussion() @discussion.reset(response.discussion_data, {silent: false}) - #rather than have two different templates to get around (or take advantage of?) - #mustache's logic free templates, we added a 'group string' to each thread for inline - #discussions for the use case where a commentable is cohorted, but a global - #thread is posted by a TA + #use same discussion template but different thread templated + #determined in the coffeescript based on whether or not there's a + #group id $discussion = $(Mustache.render $("script#_inline_discussion").html(), {'threads':response.discussion_data, 'discussionId': discussionId, 'allow_anonymous_to_peers': allow_anonymous_to_peers, 'allow_anonymous': allow_anonymous}) - + if @$('section.discussion').length @$('section.discussion').replaceWith($discussion) else diff --git a/common/static/coffee/src/discussion/views/discussion_thread_view_inline.coffee b/common/static/coffee/src/discussion/views/discussion_thread_view_inline.coffee index 7dab9ae342..e648955d08 100644 --- a/common/static/coffee/src/discussion/views/discussion_thread_view_inline.coffee +++ b/common/static/coffee/src/discussion/views/discussion_thread_view_inline.coffee @@ -16,7 +16,10 @@ if Backbone? @$delegateElement = @$local render: -> - @template = DiscussionUtil.getTemplate("_inline_thread") + if @model.has('group_id') + @template = DiscussionUtil.getTemplate("_inline_thread_cohorted") + else + @template = DiscussionUtil.getTemplate("_inline_thread") if not @model.has('abbreviatedBody') @abbreviateBody() diff --git a/lms/djangoapps/django_comment_client/forum/views.py b/lms/djangoapps/django_comment_client/forum/views.py index 6de453e1ee..269bdfcd5e 100644 --- a/lms/djangoapps/django_comment_client/forum/views.py +++ b/lms/djangoapps/django_comment_client/forum/views.py @@ -61,7 +61,8 @@ def get_threads(request, course_id, discussion_id=None, per_page=THREADS_PER_PAG #if the course-user is cohorted, then add the group id - group_id = get_cohort_id(user, course_id) + group_id = get_cohort_id(request.user, course_id) + if group_id: default_query_params["group_id"] = group_id @@ -73,11 +74,12 @@ def get_threads(request, course_id, discussion_id=None, per_page=THREADS_PER_PAG threads, page, num_pages = cc.Thread.search(query_params) + #now add the group name if the thread has a group id for thread in threads: if thread.get('group_id'): thread['group_name'] = get_cohort_by_id(course_id, thread.get('group_id')).name - thread['group_string'] = "This post visible only to Group ${group_name}." + thread['group_string'] = "This post visible only to Group %s." % (thread['group_name']) else: thread['group_name'] = "" thread['group_string'] = "This post visible to everyone." @@ -111,6 +113,9 @@ def inline_discussion(request, course_id, discussion_id): allow_anonymous = course.metadata.get("allow_anonymous", True) allow_anonymous_to_peers = course.metadata.get("allow_anonymous_to_peers", False) + #since inline is all one commentable, only show or allow the choice of cohorts + #if the commentable is cohorted, otherwise everything is not cohorted + #and no one has the option of choosing a cohort is_cohorted = is_course_cohorted(course_id) and is_commentable_cohorted(course_id, discussion_id) cohorts_list = list() @@ -118,17 +123,24 @@ def inline_discussion(request, course_id, discussion_id): if is_cohorted: #if you're a mod, send all cohorts and let you pick - if cached_has_permission(request.user, "see_all_cohorts", course_id) or True: + if cached_has_permission(request.user, "see_all_cohorts", course_id): cohorts = get_course_cohorts(course_id) for c in cohorts: cohorts_list.append({'name':c.name, 'id':c.id}) else: #otherwise, just make a dictionary of two - user_cohort = get_cohort_id(user, course_id) + user_cohort = get_cohort(user, course_id) + if user_cohort: + user_cohort_name = user_cohort.name + user_cohort_id = user_cohort.id + else: + user_cohort_name = user_cohort_id = None + + cohorts_list.append({'name':'All Groups','id':None}) if user_cohort: - cohorts_list.append({'name':user_cohort.name, 'id':user_cohort.id}) + cohorts_list.append({'name':user_cohort_name, 'id':user_cohort_id}) else: cohorts_list = None @@ -297,7 +309,7 @@ def single_thread(request, course_id, discussion_id, thread_id): 'roles': saxutils.escape(json.dumps(utils.get_role_ids(course_id)), escapedict), 'thread_pages': query_params['num_pages'], 'is_course_cohorted': is_course_cohorted(course_id), - 'is_moderator': cached_has_permission(request.user, "see_all_cohorts", course_id) or True, + 'is_moderator': cached_has_permission(request.user, "see_all_cohorts", course_id), 'cohorts': cohorts, 'user_cohort': get_cohort_id(request.user, course_id), 'cohorted_commentables': cohorted_commentables diff --git a/lms/templates/discussion/mustache/_inline_discussion.mustache b/lms/templates/discussion/mustache/_inline_discussion.mustache index c9252bd9f3..6c57fa9dfe 100644 --- a/lms/templates/discussion/mustache/_inline_discussion.mustache +++ b/lms/templates/discussion/mustache/_inline_discussion.mustache @@ -34,7 +34,6 @@
{{#threads}} -
{{group_string}}
{{/threads}} diff --git a/lms/templates/discussion/mustache/_inline_thread.mustache b/lms/templates/discussion/mustache/_inline_thread.mustache index 150625bfae..b52d3924e7 100644 --- a/lms/templates/discussion/mustache/_inline_thread.mustache +++ b/lms/templates/discussion/mustache/_inline_thread.mustache @@ -1,5 +1,4 @@
-
    diff --git a/lms/templates/discussion/mustache/_inline_thread_cohorted.mustache b/lms/templates/discussion/mustache/_inline_thread_cohorted.mustache new file mode 100644 index 0000000000..9223dfd388 --- /dev/null +++ b/lms/templates/discussion/mustache/_inline_thread_cohorted.mustache @@ -0,0 +1,22 @@ + \ No newline at end of file From 6b4a1dfd3446034be41763932d6e766a561ceb89 Mon Sep 17 00:00:00 2001 From: Your Name Date: Wed, 6 Feb 2013 12:54:06 -0500 Subject: [PATCH 18/18] minor tweaks after testing --- lms/templates/discussion/_new_post.html | 2 +- lms/templates/discussion/_thread_list_template.html | 6 ------ lms/templates/discussion/_underscore_templates.html | 1 - 3 files changed, 1 insertion(+), 8 deletions(-) diff --git a/lms/templates/discussion/_new_post.html b/lms/templates/discussion/_new_post.html index 223b593368..4c37c347ba 100644 --- a/lms/templates/discussion/_new_post.html +++ b/lms/templates/discussion/_new_post.html @@ -47,7 +47,7 @@ %endif %if is_course_cohorted: -
    +
      diff --git a/lms/templates/discussion/_underscore_templates.html b/lms/templates/discussion/_underscore_templates.html index 9182323568..3ad8a8a9d2 100644 --- a/lms/templates/discussion/_underscore_templates.html +++ b/lms/templates/discussion/_underscore_templates.html @@ -26,7 +26,6 @@
      - ${"<% if (obj.group_id) { %>"}
      ${"<%- obj.group_string%>"}.
      ${"<% } %>"}