@transaction.non_atomic_requests
@ensure_csrf_cookie
@cache_control(no_cache=True, no_store=True, must_revalidate=True)
@require_global_staff
@require_POST
def start_certificate_regeneration(request, course_id):
 course_key = CourseKey.from_string(course_id)
 certificates_statuses = request.POST.getlist('certificate_statuses', [])
 if (not certificates_statuses):
  return JsonResponse({'message': _('Please select one or more certificate statuses that require certificate regeneration.')}, status=400)
 allowed_statuses = [CertificateStatuses.downloadable, CertificateStatuses.error, CertificateStatuses.notpassing, CertificateStatuses.audit_passing, CertificateStatuses.audit_notpassing]
 if (not set(certificates_statuses).issubset(allowed_statuses)):
  return JsonResponse({'message': _('Please select certificate statuses from the list only.')}, status=400)
 try:
  lms.djangoapps.instructor_task.api.regenerate_certificates(request, course_key, certificates_statuses)
 except AlreadyRunningError as error:
  return JsonResponse({'message': error.message}, status=400)
 response_payload = {'message': _('Certificate regeneration task has been started. You can view the status of the generation task in the "Pending Tasks" section.'), 'success': True}
 return JsonResponse(response_payload)

@ transaction . non_atomic_requests @ ensure_csrf_cookie @ cache_control ( no_cache = True , no_store = True , must_revalidate = True ) @ require_global_staff @ require_POST def start_certificate_regeneration ( request , course_id ) : course_key = CourseKey . from_string ( course_id ) certificates_statuses = request . POST . getlist ( 'certificate_statuses' , [ ] ) if ( not certificates_statuses ) : return JsonResponse ( { 'message' : _ ( 'Please select one or more certificate statuses that require certificate regeneration.' ) } , status = 400 ) allowed_statuses = [ CertificateStatuses . downloadable , CertificateStatuses . error , CertificateStatuses . notpassing , CertificateStatuses . audit_passing , CertificateStatuses . audit_notpassing ] if ( not set ( certificates_statuses ) . issubset ( allowed_statuses ) ) : return JsonResponse ( { 'message' : _ ( 'Please select certificate statuses from the list only.' ) } , status = 400 ) try : lms . djangoapps . instructor_task . api . regenerate_certificates ( request , course_key , certificates_statuses ) except AlreadyRunningError as error : return JsonResponse ( { 'message' : error . message } , status = 400 ) response_payload = { 'message' : _ ( 'Certificate regeneration task has been started. You can view the status of the generation task in the "Pending Tasks" section.' ) , 'success' : True } return JsonResponse ( response_payload )
start regenerating certificates for students whose certificate statuses lie with in certificate_statuses entry in post data .