@cache_control(no_cache=True, no_store=True, must_revalidate=True)
@require_level('staff')
@require_GET
def look_up_registration_code(request, course_id):
 course_key = SlashSeparatedCourseKey.from_deprecated_string(course_id)
 code = request.GET.get('registration_code')
 course = get_course_by_id(course_key, depth=0)
 try:
  registration_code = CourseRegistrationCode.objects.get(code=code)
 except CourseRegistrationCode.DoesNotExist:
  return JsonResponse({'is_registration_code_exists': False, 'is_registration_code_valid': False, 'is_registration_code_redeemed': False, 'message': _('The enrollment code ({code}) was not found for the {course_name} course.').format(code=code, course_name=course.display_name)}, status=400)
 reg_code_already_redeemed = RegistrationCodeRedemption.is_registration_code_redeemed(code)
 registration_code_detail_url = reverse('registration_code_details', kwargs={'course_id': unicode(course_id)})
 return JsonResponse({'is_registration_code_exists': True, 'is_registration_code_valid': registration_code.is_valid, 'is_registration_code_redeemed': reg_code_already_redeemed, 'registration_code_detail_url': registration_code_detail_url})

@ cache_control ( no_cache = True , no_store = True , must_revalidate = True ) @ require_level ( 'staff' ) @ require_GET def look_up_registration_code ( request , course_id ) : course_key = SlashSeparatedCourseKey . from_deprecated_string ( course_id ) code = request . GET . get ( 'registration_code' ) course = get_course_by_id ( course_key , depth = 0 ) try : registration_code = CourseRegistrationCode . objects . get ( code = code ) except CourseRegistrationCode . DoesNotExist : return JsonResponse ( { 'is_registration_code_exists' : False , 'is_registration_code_valid' : False , 'is_registration_code_redeemed' : False , 'message' : _ ( 'The enrollment code ({code}) was not found for the {course_name} course.' ) . format ( code = code , course_name = course . display_name ) } , status = 400 ) reg_code_already_redeemed = RegistrationCodeRedemption . is_registration_code_redeemed ( code ) registration_code_detail_url = reverse ( 'registration_code_details' , kwargs = { 'course_id' : unicode ( course_id ) } ) return JsonResponse ( { 'is_registration_code_exists' : True , 'is_registration_code_valid' : registration_code . is_valid , 'is_registration_code_redeemed' : reg_code_already_redeemed , 'registration_code_detail_url' : registration_code_detail_url } )
look for the registration_code in the database .