mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-28 06:15:17 +00:00
Add print and capture permission for orders
This commit is contained in:
@@ -8,10 +8,10 @@ module Spree
|
||||
include OpenFoodNetwork::SpreeApiKeyLoader
|
||||
helper CheckoutHelper
|
||||
|
||||
before_action :load_order, only: [:edit, :update, :fire, :resend, :invoice, :print]
|
||||
before_action :load_order,
|
||||
only: [:edit, :update, :fire, :resend, :invoice, :print, :capture, :ship]
|
||||
before_action :load_distribution_choices, only: [:new, :create, :edit, :update]
|
||||
before_action :require_distributor_abn, only: :invoice
|
||||
before_action :authorize_order, only: [:capture, :ship]
|
||||
|
||||
def index
|
||||
orders = SearchOrders.new(search_params, spree_current_user).orders
|
||||
@@ -125,7 +125,6 @@ module Spree
|
||||
|
||||
def ship
|
||||
@order.send_shipment_email = false unless params[:send_shipment_email]
|
||||
@order.send_shipment_email
|
||||
if @order.ship
|
||||
if params[:current_page] != 'index'
|
||||
return redirect_back fallback_location: admin_orders_path
|
||||
@@ -263,11 +262,6 @@ module Spree
|
||||
authorize! action, @order
|
||||
end
|
||||
|
||||
def authorize_order
|
||||
@order = Spree::Order.find_by(number: params[:id])
|
||||
authorize! :admin, @order
|
||||
end
|
||||
|
||||
def set_param_for_controller
|
||||
redirect_back fallback_location: admin_orders_path
|
||||
params[:id] = @order.number
|
||||
|
||||
@@ -266,7 +266,8 @@ module Spree
|
||||
|
||||
def add_order_management_abilities(user)
|
||||
can [:index, :create], Spree::Order
|
||||
can [:read, :update, :fire, :resend, :invoice, :print], Spree::Order do |order|
|
||||
can [:read, :update, :fire, :resend, :invoice, :print, :ship, :capture],
|
||||
Spree::Order do |order|
|
||||
# We allow editing orders with a nil distributor as this state occurs
|
||||
# during the order creation process from the admin backend
|
||||
order.distributor.nil? ||
|
||||
|
||||
Reference in New Issue
Block a user