@login_required
@require_http_methods(('POST',))
@ensure_csrf_cookie
def certificate_activation_handler(request, course_key_string):
 course_key = CourseKey.from_string(course_key_string)
 store = modulestore()
 try:
  course = _get_course_and_check_access(course_key, request.user)
 except PermissionDenied:
  msg = _('PermissionDenied: Failed in authenticating {user}').format(user=request.user)
  return JsonResponse({'error': msg}, status=403)
 data = json.loads(request.body)
 is_active = data.get('is_active', False)
 certificates = CertificateManager.get_certificates(course)
 for certificate in certificates:
  certificate['is_active'] = is_active
  break
 store.update_item(course, request.user.id)
 cert_event_type = ('activated' if is_active else 'deactivated')
 CertificateManager.track_event(cert_event_type, {'course_id': unicode(course.id)})
 return HttpResponse(status=200)

@ login_required @ require_http_methods ( ( 'POST' , ) ) @ ensure_csrf_cookie def certificate_activation_handler ( request , course_key_string ) : course_key = CourseKey . from_string ( course_key_string ) store = modulestore ( ) try : course = _get_course_and_check_access ( course_key , request . user ) except PermissionDenied : msg = _ ( 'PermissionDenied: Failed in authenticating {user}' ) . format ( user = request . user ) return JsonResponse ( { 'error' : msg } , status = 403 ) data = json . loads ( request . body ) is_active = data . get ( 'is_active' , False ) certificates = CertificateManager . get_certificates ( course ) for certificate in certificates : certificate [ 'is_active' ] = is_active break store . update_item ( course , request . user . id ) cert_event_type = ( 'activated' if is_active else 'deactivated' ) CertificateManager . track_event ( cert_event_type , { 'course_id' : unicode ( course . id ) } ) return HttpResponse ( status = 200 )
a handler for certificate activation/deactivation post json: is_active .