def _vote_or_unvote(request, course_id, obj, value='up', undo_vote=False):
 course_key = CourseKey.from_string(course_id)
 course = get_course_with_access(request.user, 'load', course_key)
 user = cc.User.from_django_user(request.user)
 if undo_vote:
  user.unvote(obj)
 else:
  user.vote(obj, value)
 track_voted_event(request, course, obj, value, undo_vote)
 return JsonResponse(prepare_content(obj.to_dict(), course_key))

def _vote_or_unvote ( request , course_id , obj , value = 'up' , undo_vote = False ) : course_key = CourseKey . from_string ( course_id ) course = get_course_with_access ( request . user , 'load' , course_key ) user = cc . User . from_django_user ( request . user ) if undo_vote : user . unvote ( obj ) else : user . vote ( obj , value ) track_voted_event ( request , course , obj , value , undo_vote ) return JsonResponse ( prepare_content ( obj . to_dict ( ) , course_key ) )
vote or unvote for a thread or a response .