Skip to content

Commit

Permalink
Use Spree.url() to add tokens to API calls to stock_locations
Browse files Browse the repository at this point in the history
On 2.0, stock_locations AJAX class are getting a 401 on http://localhost:3000/admin/stock_transfers/new since securing the stock locations API end points.

Fixes spree#3828
  • Loading branch information
AlainPilon authored and radar committed Oct 8, 2013
1 parent 9741b8f commit d38226d
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions backend/app/assets/javascripts/admin/stock_transfer.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ $ ->

$('#transfer_receive_stock').change (event) => @receive_stock_change(event)

$.getJSON Spree.routes.stock_locations_api, (data) =>
$.getJSON Spree.url(Spree.routes.stock_locations_api), (data) =>
@locations = (location for location in data.stock_locations)
@force_receive_stock() if @locations.length < 2

Expand Down Expand Up @@ -92,13 +92,13 @@ $ ->
if @cached_variants?
@populate_select @cached_variants
else
$.getJSON Spree.routes.variants_api, (data) =>
$.getJSON Spree.url(Spree.routes.variants_api), (data) =>
@cached_variants = _.map(data.variants, (variant) -> new TransferVariant(variant))
@populate_select @cached_variants

_refresh_transfer_stock_items: ->
stock_location_id = $('#transfer_source_location_id').val()
$.getJSON Spree.routes.stock_locations_api + "/#{stock_location_id}/stock_items", (data) =>
$.getJSON Spree.url(Spree.routes.stock_locations_api + "/#{stock_location_id}/stock_items"), (data) =>
@populate_select _.map(data.stock_items, (stock_item) -> new TransferStockItem(stock_item))

populate_select: (variants) ->
Expand Down Expand Up @@ -177,5 +177,3 @@ $ ->
transfer_locations = new TransferLocations
transfer_variants = new TransferVariants
transfer_add_variants = new TransferAddVariants


0 comments on commit d38226d

Please sign in to comment.