'Create a New Organization
Create a new organization owned by the request\'s user.  To create
an organization only the name is required.
:param string name: the human readable name for the new organization.
:param string slug: the unique URL slug for this organization.  If
this is not provided a slug is automatically
generated based on the name.
:auth: required, user-context-needed'

def post(self, request):

    if (not request.user.is_authenticated()):
        return Response({'detail': 'This    endpoint    requires    user    info'}, status=401)
    if (not features.has('organizations:create', actor=request.user)):
        return Response({'detail': 'Organizations    are    not    allowed    to    be    created    by    this    user.'}, status=401)
    limit = options.get('api.rate-limit.org-create')
    if (limit and ratelimiter.is_limited(u'org-create:{}'.format(request.user.id), limit=limit, window=3600)):
        return Response({'detail': 'You    are    attempting    to    create    too    many    organizations    too    quickly.'}, status=429)
    serializer = OrganizationSerializer(data=request.DATA)
    if serializer.is_valid():
        result = serializer.object
        try:
            with transaction.atomic():
                org = Organization.objects.create(name=result['name'], slug=result.get('slug'))
        except IntegrityError:
            return Response({'detail': 'An    organization    with    this    slug    already    exists.'}, status=409)
        om = OrganizationMember.objects.create(organization=org, user=request.user, role=roles.get_top_dog().id)
        if result.get('defaultTeam'):
            team = org.team_set.create(name=org.name)
            OrganizationMemberTeam.objects.create(team=team, organizationmember=om, is_active=True)
        self.create_audit_entry(request=request, organization=org, target_object=org.id, event=AuditLogEntryEvent.ORG_ADD, data=org.get_audit_log_data())
        analytics.record('organization.created', org, actor_id=(request.user.id if request.user.is_authenticated() else None))
        return Response(serialize(org, request.user), status=201)
    return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
