produce and consume group_id from dropdowns

This commit is contained in:
Kevin Chugh
2013-02-02 05:46:11 -05:00
parent 8fd32ed502
commit fcbd4bd1cd
5 changed files with 17 additions and 14 deletions

View File

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