@ensure_csrf_cookie
@cache_control(no_cache=True, no_store=True, must_revalidate=True)
@require_level('staff')
def get_sale_records(request, course_id, csv=False):
 course_id = SlashSeparatedCourseKey.from_deprecated_string(course_id)
 query_features = ['company_name', 'company_contact_name', 'company_contact_email', 'total_codes', 'total_used_codes', 'total_amount', 'created', 'customer_reference_number', 'recipient_name', 'recipient_email', 'created_by', 'internal_reference', 'invoice_number', 'codes', 'course_id']
 sale_data = instructor_analytics.basic.sale_record_features(course_id, query_features)
 if (not csv):
  for item in sale_data:
   item['created_by'] = item['created_by'].username
  response_payload = {'course_id': course_id.to_deprecated_string(), 'sale': sale_data, 'queried_features': query_features}
  return JsonResponse(response_payload)
 else:
  (header, datarows) = instructor_analytics.csvs.format_dictlist(sale_data, query_features)
  return instructor_analytics.csvs.create_csv_response('e-commerce_sale_invoice_records.csv', header, datarows)

@ ensure_csrf_cookie @ cache_control ( no_cache = True , no_store = True , must_revalidate = True ) @ require_level ( 'staff' ) def get_sale_records ( request , course_id , csv = False ) : course_id = SlashSeparatedCourseKey . from_deprecated_string ( course_id ) query_features = [ 'company_name' , 'company_contact_name' , 'company_contact_email' , 'total_codes' , 'total_used_codes' , 'total_amount' , 'created' , 'customer_reference_number' , 'recipient_name' , 'recipient_email' , 'created_by' , 'internal_reference' , 'invoice_number' , 'codes' , 'course_id' ] sale_data = instructor_analytics . basic . sale_record_features ( course_id , query_features ) if ( not csv ) : for item in sale_data : item [ 'created_by' ] = item [ 'created_by' ] . username response_payload = { 'course_id' : course_id . to_deprecated_string ( ) , 'sale' : sale_data , 'queried_features' : query_features } return JsonResponse ( response_payload ) else : ( header , datarows ) = instructor_analytics . csvs . format_dictlist ( sale_data , query_features ) return instructor_analytics . csvs . create_csv_response ( 'e-commerce_sale_invoice_records.csv' , header , datarows )
return the summary of all sales records for a particular course .