       source_type: 'external'
       params: params
 
-    tools = []
-    for toolType, index in Toolsets.projects[Manager.get('project')].defaults
-      tool =
-        tool_type: toolType
-        name: "#{toolType}-#{index}"
-        data_source: dataSource
-      tool.settings = settings unless _.isUndefined(settings)
-      tools.push tool
+    toolset = Toolsets.projects[Manager.get('project')].defaults
+    tools = @createTools(toolset, dataSource, settings)
 
-    @dashboardModel = new DashboardModel
-      name: name
-      project: Manager.get('project')
-      tools: tools
+    @dashboardModel = @createDashboard(name, tools)
     
     @dashboardModel.save().done =>
       @navigateToDashboard()

      source_type: 'external'
      params: paramsFormatted

    toolsFormatted = new Array
    for toolType, index in tools
      toolFormatted = 
        tool_type: toolType
        name: "#{toolType}-#{index}"
        data_source: dataSource
      toolsFormatted.push toolFormatted

    @dashboardModel = new DashboardModel
      name: name.join(' ')
      project: Manager.get('project')
      tools: toolsFormatted

    @dashboardModel.save().done =>
      @navigateToDashboard()

  loadDashboard: (id) =>
    @dashboardModel = new DashboardModel {id: id}
    @dashboardModel.fetch
      success: => ToolLoader @dashboardModel, @createDashboardView
      error: =>
        delete @dashboardModel
        Manager.get('router').navigate '', {trigger: true}

      ToolLoader @dashboardModel, @createDashboardView
    return @dashboardModel

  createTools: (tools, dataSource, settings=null) ->
    _.each(tools, (toolType, index) ->
      tool = 
        tool_type: toolType
        name: "#{toolType}-#{index}"
        data_source: dataSource
      tool.settings = settings if settings?)

  createDashboard: (name, tools, project=null) ->
    new DashboardModel
      name: name
      project: (project or Manager.get('project'))
      tools: tools

  createDashboardFromZooid: (name, zooid, settings) ->
    params = [ {key: 'id', val: zooid} ]

