Show message about resumable orders when unpausing a subscription

This commit is contained in:
Rob Harrington
2018-02-21 18:56:59 +11:00
parent 7332e21013
commit b98afc00ba
5 changed files with 77 additions and 8 deletions

View File

@@ -7,6 +7,7 @@ module Admin
before_filter :strip_banned_attrs, only: [:update]
before_filter :wrap_nested_attrs, only: [:create, :update]
before_filter :check_for_open_orders, only: [:cancel, :pause]
before_filter :check_for_canceled_orders, only: [:unpause]
respond_to :json
def index
@@ -125,6 +126,12 @@ module Admin
render json: { errors: { open_orders: t('admin.subscriptions.confirm_cancel_open_orders_msg') } }, status: :conflict
end
def check_for_canceled_orders
return if params[:canceled_orders] == 'notified'
return if @subscription.proxy_orders.active.canceled.empty?
render json: { errors: { canceled_orders: t('admin.subscriptions.resume_canceled_orders_msg') } }, status: :conflict
end
def strip_banned_attrs
params[:subscription].delete :schedule_id
params[:subscription].delete :customer_id