def remove_certificate_exception(course_key, student):
 try:
  certificate_exception = CertificateWhitelist.objects.get(user=student, course_id=course_key)
 except ObjectDoesNotExist:
  raise ValueError(_('Certificate exception (user={user}) does not exist in certificate white list. Please refresh the page and try again.').format(user=student.username))
 try:
  generated_certificate = GeneratedCertificate.objects.get(user=student, course_id=course_key)
  generated_certificate.invalidate()
  log.info(u'Certificate invalidated for %s in course %s when removed from certificate exception list', student.username, course_key)
 except ObjectDoesNotExist:
  pass
 certificate_exception.delete()

def remove_certificate_exception ( course_key , student ) : try : certificate_exception = CertificateWhitelist . objects . get ( user = student , course_id = course_key ) except ObjectDoesNotExist : raise ValueError ( _ ( 'Certificate exception (user={user}) does not exist in certificate white list. Please refresh the page and try again.' ) . format ( user = student . username ) ) try : generated_certificate = GeneratedCertificate . objects . get ( user = student , course_id = course_key ) generated_certificate . invalidate ( ) log . info ( u'Certificate invalidated for %s in course %s when removed from certificate exception list' , student . username , course_key ) except ObjectDoesNotExist : pass certificate_exception . delete ( )
remove certificate exception for given course and student from certificatewhitelist table and invalidate its generatedcertificate if present .