Commit fcbd4bd1 by Kevin Chugh

produce and consume group_id from dropdowns

parent 8fd32ed5
......@@ -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)
......
......@@ -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
......
......@@ -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):
......
......@@ -52,7 +52,7 @@
<div class="form-group-label choose-cohort">
Make visible to:
<select class="group-filter-select new-post-group" name = "group_id">
<option >All Groups</option>
<option value="">All Groups</option>
%if is_moderator:
%for c in cohorts:
<option value="${c.id}">${c.name}</option>
......
......@@ -26,7 +26,7 @@
<div class="discussion-post">
<div><a href="javascript:void(0)" class="dogear action-follow" data-tooltip="follow"></a></div>
<header>
%if thread['group_id']
%if 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>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment