WIP: ProxyOrders don't require an order, adding an edit path for proxy orders

initialises an order if one does not exist and redirects to its edit path
This commit is contained in:
Rob Harrington
2016-12-12 11:33:49 +11:00
parent 4b440c83a4
commit 3d3013a592
4 changed files with 10 additions and 5 deletions

View File

@@ -2,6 +2,11 @@ module Admin
class ProxyOrdersController < ResourceController
respond_to :json
def edit
@proxy_order.initialise_order! unless @proxy_order.order
redirect_to spree.edit_admin_order_path(@proxy_order.order)
end
def cancel
if @proxy_order.cancel
respond_with(@proxy_order) do |format|

View File

@@ -260,7 +260,7 @@ class AbilityDecorator
can [:destroy], StandingLineItem do |standing_line_item|
user.enterprises.include?(standing_line_item.standing_order.shop)
end
can [:admin, :cancel, :resume], ProxyOrder do |proxy_order|
can [:admin, :edit, :cancel, :resume], ProxyOrder do |proxy_order|
user.enterprises.include?(proxy_order.standing_order.shop)
end
end

View File

@@ -10,6 +10,6 @@ class Api::Admin::ProxyOrderSerializer < ActiveModel::Serializer
end
def edit_path
spree.edit_admin_order_path(object.order)
edit_admin_proxy_order_path(object)
end
end

View File

@@ -187,9 +187,9 @@ Openfoodnetwork::Application.routes.draw do
post :build, on: :collection
end
resources :proxy_orders, only: [], format: :json do
put :cancel, on: :member
put :resume, on: :member
resources :proxy_orders, only: [:edit] do
put :cancel, on: :member, format: :json
put :resume, on: :member, format: :json
end
end