mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Create a new url /orders/ORDER_ID/distribution
That handles the step when distributor and order_cycle must be selected
This commit is contained in:
@@ -9,8 +9,8 @@ module Spree
|
||||
helper CheckoutHelper
|
||||
|
||||
before_action :load_order, only: [:edit, :update, :fire, :resend,
|
||||
:invoice, :print]
|
||||
before_action :load_distribution_choices, only: [:new, :edit, :update]
|
||||
:invoice, :print, :set_distribution]
|
||||
before_action :load_distribution_choices, only: [:new, :edit, :update, :set_distribution]
|
||||
|
||||
# Ensure that the distributor is set for an order when
|
||||
before_action :ensure_distribution, only: :new
|
||||
@@ -21,10 +21,13 @@ module Spree
|
||||
def new
|
||||
@order = Order.create
|
||||
@order.created_by = spree_current_user
|
||||
@order.generate_order_number
|
||||
@order.save
|
||||
redirect_to spree.edit_admin_order_url(@order)
|
||||
redirect_to spree.distribution_admin_order_path(@order)
|
||||
end
|
||||
|
||||
def set_distribution; end
|
||||
|
||||
def edit
|
||||
@order.shipments.map(&:refresh_rates)
|
||||
|
||||
|
||||
@@ -274,7 +274,7 @@ module Spree
|
||||
# Enterprise User can access orders that are placed inside a OC they coordinate
|
||||
order.order_cycle&.coordinated_by?(user)
|
||||
end
|
||||
can [:admin, :bulk_management, :managed], Spree::Order do
|
||||
can [:admin, :bulk_management, :managed, :set_distribution], Spree::Order do
|
||||
user.admin? || user.enterprises.any?(&:is_distributor)
|
||||
end
|
||||
can [:admin, :create, :show, :poll], :invoice
|
||||
|
||||
@@ -89,6 +89,7 @@ Spree::Core::Engine.routes.draw do
|
||||
post :resend
|
||||
get :invoice
|
||||
get :print
|
||||
get :distribution, to: 'orders#set_distribution'
|
||||
end
|
||||
|
||||
collection do
|
||||
|
||||
Reference in New Issue
Block a user