mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Set environment for payment methods unless admin
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
module Spree
|
||||
module Admin
|
||||
PaymentMethodsController.class_eval do
|
||||
before_filter :force_environment, only: [:create, :update]
|
||||
skip_before_filter :load_resource, only: [:show_provider_preferences]
|
||||
before_filter :load_hubs, only: [:new, :edit, :update]
|
||||
create.before :load_hubs
|
||||
@@ -46,6 +47,10 @@ module Spree
|
||||
|
||||
private
|
||||
|
||||
def force_environment
|
||||
params[:payment_method][:environment] = Rails.env unless spree_current_user.admin?
|
||||
end
|
||||
|
||||
def load_data
|
||||
if spree_current_user.admin? || Rails.env.test?
|
||||
@providers = Gateway.providers.sort{|p1, p2| p1.name <=> p2.name }
|
||||
|
||||
Reference in New Issue
Block a user