'Join a team
Join or request access to a team.
If the user is already a member of the team, this will simply return
a 204.
If the user needs permission to join the team, an access request will
be generated and the returned status code will be 202.'

def post(self, request, organization, member_id, team_slug):

    try:
        om = self._get_member(request, organization, member_id)
    except OrganizationMember.DoesNotExist:
        raise ResourceDoesNotExist
    if (not self._can_access(request, om)):
        return Response({'detail': ERR_INSUFFICIENT_ROLE}, status=400)
    try:
        team = Team.objects.get(organization=organization, slug=team_slug)
    except Team.DoesNotExist:
        raise ResourceDoesNotExist
    try:
        omt = OrganizationMemberTeam.objects.get(team=team, organizationmember=om)
    except OrganizationMemberTeam.DoesNotExist:
        if (not (request.access.has_scope('org:write') or organization.flags.allow_joinleave)):
            (omt, created) = OrganizationAccessRequest.objects.get_or_create(team=team, member=om)
            if created:
                omt.send_request_email()
            return Response(status=202)
        omt = OrganizationMemberTeam.objects.create(team=team, organizationmember=om)
    else:
        return Response(status=204)
    self.create_audit_entry(request=request, organization=organization, target_object=omt.id, target_user=om.user, event=AuditLogEntryEvent.MEMBER_JOIN_TEAM, data=omt.get_audit_log_data())
    return Response(serialize(team, request.user, TeamWithProjectsSerializer()), status=201)
