def _validate_post_params(params):
 try:
  username = params.get('username')
  user = User.objects.get(username=username)
 except User.DoesNotExist:
  msg = _('User {username} does not exist').format(username=username)
  return (None, HttpResponseBadRequest(msg))
 try:
  course_key = CourseKey.from_string(params.get('course_key'))
 except InvalidKeyError:
  msg = _('{course_key} is not a valid course key').format(course_key=params.get('course_key'))
  return (None, HttpResponseBadRequest(msg))
 return ({'user': user, 'course_key': course_key}, None)

def _validate_post_params ( params ) : try : username = params . get ( 'username' ) user = User . objects . get ( username = username ) except User . DoesNotExist : msg = _ ( 'User {username} does not exist' ) . format ( username = username ) return ( None , HttpResponseBadRequest ( msg ) ) try : course_key = CourseKey . from_string ( params . get ( 'course_key' ) ) except InvalidKeyError : msg = _ ( '{course_key} is not a valid course key' ) . format ( course_key = params . get ( 'course_key' ) ) return ( None , HttpResponseBadRequest ( msg ) ) return ( { 'user' : user , 'course_key' : course_key } , None )
validate request post parameters to the generate and regenerate certificates end-point .