@transaction.non_atomic_requests
@ensure_csrf_cookie
@cache_control(no_cache=True, no_store=True, must_revalidate=True)
@require_level('staff')
def get_issued_certificates(request, course_id):
 course_key = CourseKey.from_string(course_id)
 csv_required = request.GET.get('csv', 'false')
 query_features = ['course_id', 'mode', 'total_issued_certificate', 'report_run_date']
 query_features_names = [('course_id', _('CourseID')), ('mode', _('Certificate Type')), ('total_issued_certificate', _('Total Certificates Issued')), ('report_run_date', _('Date Report Run'))]
 certificates_data = instructor_analytics.basic.issued_certificates(course_key, query_features)
 if (csv_required.lower() == 'true'):
  (__, data_rows) = instructor_analytics.csvs.format_dictlist(certificates_data, query_features)
  return instructor_analytics.csvs.create_csv_response('issued_certificates.csv', [col_header for (__, col_header) in query_features_names], data_rows)
 else:
  response_payload = {'certificates': certificates_data, 'queried_features': query_features, 'feature_names': dict(query_features_names)}
  return JsonResponse(response_payload)

@ transaction . non_atomic_requests @ ensure_csrf_cookie @ cache_control ( no_cache = True , no_store = True , must_revalidate = True ) @ require_level ( 'staff' ) def get_issued_certificates ( request , course_id ) : course_key = CourseKey . from_string ( course_id ) csv_required = request . GET . get ( 'csv' , 'false' ) query_features = [ 'course_id' , 'mode' , 'total_issued_certificate' , 'report_run_date' ] query_features_names = [ ( 'course_id' , _ ( 'CourseID' ) ) , ( 'mode' , _ ( 'Certificate Type' ) ) , ( 'total_issued_certificate' , _ ( 'Total Certificates Issued' ) ) , ( 'report_run_date' , _ ( 'Date Report Run' ) ) ] certificates_data = instructor_analytics . basic . issued_certificates ( course_key , query_features ) if ( csv_required . lower ( ) == 'true' ) : ( __ , data_rows ) = instructor_analytics . csvs . format_dictlist ( certificates_data , query_features ) return instructor_analytics . csvs . create_csv_response ( 'issued_certificates.csv' , [ col_header for ( __ , col_header ) in query_features_names ] , data_rows ) else : response_payload = { 'certificates' : certificates_data , 'queried_features' : query_features , 'feature_names' : dict ( query_features_names ) } return JsonResponse ( response_payload )
responds with json if csv is not required .