update to show cohort name on create and cohort name on view all threads, added cohort dictionary to convert ids to names

This commit is contained in:
Your Name
2013-02-01 13:01:54 -05:00
parent da1660a043
commit 8fd32ed502
7 changed files with 29 additions and 17 deletions

View File

@@ -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

View File

@@ -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:

View File

@@ -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

View File

@@ -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;
}

View File

@@ -55,10 +55,10 @@
<option >All Groups</option>
%if is_moderator:
%for c in cohorts:
<option value="${c.id}">${c.name}</option>
<option value="${c.id}">${c.name}</option>
%endfor
%else:
<option value="${cohort}">My Cohort</option>
<option value="${user_cohort}">My Cohort</option>
%endif
</select>

View File

@@ -5,7 +5,10 @@
<a href="#" class="dogear"></a>
<div class="discussion-post">
<header>
<div class="group-visibility-label">This post visible only to group 1. </div>
%if thread['group_id']
<div class="group-visibility-label">This post visible only to group ${cohort_dictionary[thread['group_id']]}. </div>
%endif
<a href="#" class="vote-btn discussion-vote discussion-vote-up"><span class="plus-icon">+</span> <span class='votes-count-number'>${thread['votes']['up_count']}</span></a>
<h1>${thread['title']}</h1>
<p class="posted-details">

View File

@@ -26,7 +26,9 @@
<div class="discussion-post">
<div><a href="javascript:void(0)" class="dogear action-follow" data-tooltip="follow"></a></div>
<header>
<div class="group-visibility-label">This post visible only to Group 1.</div>
%if thread['group_id']
<div class="group-visibility-label">This post visible only to Group ${cohort_dictionary[thread['group_id']]}.</div>
%endif
<a href="#" class="vote-btn discussion-vote discussion-vote-up" data-role="discussion-vote" data-tooltip="vote"><span class="plus-icon">+</span> <span class='votes-count-number'>${'<%- votes["up_count"] %>'}</span></a>
<h1>${'<%- title %>'}</h1>
<p class="posted-details">