def delete_redemption_entry(request, code_redemption, course_key):
 user = code_redemption.redeemed_by
 email_address = code_redemption.redeemed_by.email
 full_name = code_redemption.redeemed_by.profile.name
 CourseEnrollment.unenroll(user, course_key, skip_refund=True)
 course = get_course_by_id(course_key, depth=0)
 email_params = get_email_params(course, True, secure=request.is_secure())
 email_params['message'] = 'enrolled_unenroll'
 email_params['email_address'] = email_address
 email_params['full_name'] = full_name
 send_mail_to_student(email_address, email_params)
 log.info('deleting redemption entry (%s) from the database.', code_redemption.id)
 code_redemption.delete()

def delete_redemption_entry ( request , code_redemption , course_key ) : user = code_redemption . redeemed_by email_address = code_redemption . redeemed_by . email full_name = code_redemption . redeemed_by . profile . name CourseEnrollment . unenroll ( user , course_key , skip_refund = True ) course = get_course_by_id ( course_key , depth = 0 ) email_params = get_email_params ( course , True , secure = request . is_secure ( ) ) email_params [ 'message' ] = 'enrolled_unenroll' email_params [ 'email_address' ] = email_address email_params [ 'full_name' ] = full_name send_mail_to_student ( email_address , email_params ) log . info ( 'deleting redemption entry (%s) from the database.' , code_redemption . id ) code_redemption . delete ( )
delete the redemption entry from the table and unenroll the user who used the registration code for the enrollment and send him/her the unenrollment email .