 
     # saves the new shipment (bound to currentShipment) to the db
     saveShipment: (shipment, ignoreWarnings) ->
-      $.ajax({
-        type: 'GET'
-        url: "/trade/user_can_edit"
-        data: {}
-        dataType: 'json'
-        success: (response) ->
-          console.log(response)
-        error: (error) ->
-          console.log(error)
-      })
       shipment.set('ignoreWarnings', ignoreWarnings)
       # Before trying to save a shipment
       # we need to reset the model to a valid state.

    @set('page', page)
    @transitionToRoute('search.results', {queryParams: {page: page}})

  actions:
    newShipment: () ->
      shipment = Trade.Shipment.createRecord()


    # discards the new shipment (bound to currentShipment)
    deleteShipment: (shipment) ->
      @userCanEdit( =>
        if confirm("This will delete a shipment. Proceed?")
          if (!shipment.get('isSaving'))
            shipment.deleteRecord()
            shipment.get('transaction').commit()
            shipment.one('didDelete', this, ->
              @set('currentShipment', null)
              @flashSuccess(message: 'Successfully deleted shipment.')
              @send("dataChanged")
            )
      )

    deleteBatch: ->
      @userCanEdit( =>
        @transitionToRoute('search.results', {queryParams: @get('controllers.search.searchParams')})
        .then(
          # resolve
          (() =>
            if confirm("This will delete " + @get('total') + " shipments. Are you sure?")
              $.ajax(
                url: '/trade/shipments/destroy_batch'
                type: 'POST'
                data:
                  filters: @get('controllers.search.searchParams')
              )
              .done( (data) =>
                @flashSuccess(message: 'Successfully deleted ' + data.rows + ' shipments.')
                @send("dataChanged")
              )
              .fail( (xhr) =>
                @flashError(message: 'Error occurred when deleting shipments.')
                console.log "bad luck: ", xhr.responseText
              )
              .always( () =>
                @set('currentShipment', null)
                $('.batch-form-modal').modal('hide')
              )
          )
        )
      )

