Only show payment methods that user has access to

This commit is contained in:
David Cook
2013-08-19 11:29:54 +10:00
parent c1f9d9789d
commit 4be2fe5fe9

View File

@@ -0,0 +1,14 @@
Spree::Admin::PaymentMethodsController.class_eval do
# Only show payment methods that user has access to.
# ! Redundant code copied from Spree::Admin::ResourceController with two added lines
def collection
return parent.send(controller_name) if parent_data.present?
if model_class.respond_to?(:accessible_by) && !current_ability.has_block?(params[:action], model_class)
model_class.accessible_by(current_ability, action).
managed_by(spree_current_user) # this line added
else
model_class.scoped.
managed_by(spree_current_user) # this line added
end
end
end