def get_reg_code_validity(registration_code, request, limiter):
 reg_code_already_redeemed = False
 course_registration = None
 try:
  course_registration = CourseRegistrationCode.objects.get(code=registration_code)
 except CourseRegistrationCode.DoesNotExist:
  reg_code_is_valid = False
 else:
  if course_registration.is_valid:
   reg_code_is_valid = True
  else:
   reg_code_is_valid = False
  reg_code_already_redeemed = RegistrationCodeRedemption.is_registration_code_redeemed(registration_code)
 if (not reg_code_is_valid):
  AUDIT_LOG.info('Redemption of a invalid RegistrationCode %s', registration_code)
  limiter.tick_bad_request_counter(request)
  raise Http404()
 return (reg_code_is_valid, reg_code_already_redeemed, course_registration)

def get_reg_code_validity ( registration_code , request , limiter ) : reg_code_already_redeemed = False course_registration = None try : course_registration = CourseRegistrationCode . objects . get ( code = registration_code ) except CourseRegistrationCode . DoesNotExist : reg_code_is_valid = False else : if course_registration . is_valid : reg_code_is_valid = True else : reg_code_is_valid = False reg_code_already_redeemed = RegistrationCodeRedemption . is_registration_code_redeemed ( registration_code ) if ( not reg_code_is_valid ) : AUDIT_LOG . info ( 'Redemption of a invalid RegistrationCode %s' , registration_code ) limiter . tick_bad_request_counter ( request ) raise Http404 ( ) return ( reg_code_is_valid , reg_code_already_redeemed , course_registration )
this function checks if the registration code is valid .