@ensure_csrf_cookie
@require_POST
def remove_user_from_cohort(request, course_key_string, cohort_id):
 course_key = SlashSeparatedCourseKey.from_deprecated_string(course_key_string)
 get_course_with_access(request.user, 'staff', course_key)
 username = request.POST.get('username')
 if (username is None):
  return json_http_response({'success': False, 'msg': 'No username specified'})
 try:
  user = User.objects.get(username=username)
 except User.DoesNotExist:
  log.debug('no user')
  return json_http_response({'success': False, 'msg': "No user '{0}'".format(username)})
 try:
  membership = CohortMembership.objects.get(user=user, course_id=course_key)
  membership.delete()
 except CohortMembership.DoesNotExist:
  pass
 return json_http_response({'success': True})

@ ensure_csrf_cookie @ require_POST def remove_user_from_cohort ( request , course_key_string , cohort_id ) : course_key = SlashSeparatedCourseKey . from_deprecated_string ( course_key_string ) get_course_with_access ( request . user , 'staff' , course_key ) username = request . POST . get ( 'username' ) if ( username is None ) : return json_http_response ( { 'success' : False , 'msg' : 'No username specified' } ) try : user = User . objects . get ( username = username ) except User . DoesNotExist : log . debug ( 'no user' ) return json_http_response ( { 'success' : False , 'msg' : "No user '{0}'" . format ( username ) } ) try : membership = CohortMembership . objects . get ( user = user , course_id = course_key ) membership . delete ( ) except CohortMembership . DoesNotExist : pass return json_http_response ( { 'success' : True } )
look up the given user .