From 8fd32ed5026f9fb4fd287958acef933373c2797e Mon Sep 17 00:00:00 2001 From: Your Name Date: Fri, 1 Feb 2013 13:01:54 -0500 Subject: [PATCH] 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 %>'}