'Creates a new CCX course for a given Master Course.
Args:
request (Request): Django request object.
Return:
A JSON serialized representation a newly created CCX course.'

def post(self, request):

    master_course_id = request.data.get('master_course_id')
    (master_course_object, master_course_key, error_code, http_status) = get_valid_course(master_course_id, advanced_course_check=True)
    if (master_course_object is None):
        return Response(status=http_status, data={'error_code': error_code})
    (valid_input, field_errors) = get_valid_input(request.data)
    if field_errors:
        return Response(status=status.HTTP_400_BAD_REQUEST, data={'field_errors': field_errors})
    try:
        coach = User.objects.get(email=valid_input['coach_email'])
    except User.DoesNotExist:
        return Response(status=status.HTTP_404_NOT_FOUND, data={'error_code': 'coach_user_does_not_exist'})
    if valid_input.get('course_modules'):
        if (not valid_course_modules(valid_input['course_modules'], master_course_key)):
            return Response(status=status.HTTP_400_BAD_REQUEST, data={'error_code': 'course_module_list_not_belonging_to_master_course'})
    course_modules_json = json.dumps(valid_input.get('course_modules'))
    with transaction.atomic():
        ccx_course_object = CustomCourseForEdX(course_id=master_course_object.id, coach=coach, display_name=valid_input['display_name'], structure_json=course_modules_json)
        ccx_course_object.save()
        start = TODAY().replace(tzinfo=pytz.UTC)
        override_field_for_ccx(ccx_course_object, master_course_object, 'start', start)
        override_field_for_ccx(ccx_course_object, master_course_object, 'due', None)
        override_field_for_ccx(ccx_course_object, master_course_object, 'max_student_enrollments_allowed', valid_input['max_students_allowed'])
        hidden = 'visible_to_staff_only'
        for chapter in master_course_object.get_children():
            override_field_for_ccx(ccx_course_object, chapter, hidden, True)
            for sequential in chapter.get_children():
                override_field_for_ccx(ccx_course_object, sequential, hidden, True)
                for vertical in sequential.get_children():
                    override_field_for_ccx(ccx_course_object, vertical, hidden, True)
        make_user_coach(coach, master_course_key)
        ccx_course_key = CCXLocator.from_course_locator(master_course_object.id, unicode(ccx_course_object.id))
        email_params = get_email_params(master_course_object, auto_enroll=True, course_key=ccx_course_key, display_name=ccx_course_object.display_name)
        enroll_email(course_id=ccx_course_key, student_email=coach.email, auto_enroll=True, email_students=True, email_params=email_params)
        assign_staff_role_to_ccx(ccx_course_key, coach, master_course_object.id)
        add_master_course_staff_to_ccx(master_course_object, ccx_course_key, ccx_course_object.display_name, send_email=False)
    serializer = self.get_serializer(ccx_course_object)
    responses = SignalHandler.course_published.send(sender=ccx_course_object, course_key=ccx_course_key)
    for (rec, response) in responses:
        log.info('Signal    fired    when    course    is    published.    Receiver:    %s.    Response:    %s', rec, response)
    return Response(status=status.HTTP_201_CREATED, data=serializer.data)
