mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-10 23:07:47 +00:00
Add search_controller from spree_backend so that we can now merge it with the OFN's decorator
This commit is contained in:
27
app/controllers/spree/admin/search_controller.rb
Normal file
27
app/controllers/spree/admin/search_controller.rb
Normal file
@@ -0,0 +1,27 @@
|
||||
module Spree
|
||||
module Admin
|
||||
class SearchController < Spree::Admin::BaseController
|
||||
# http://spreecommerce.com/blog/2010/11/02/json-hijacking-vulnerability/
|
||||
before_filter :check_json_authenticity, :only => :index
|
||||
respond_to :json
|
||||
|
||||
# TODO: Clean this up by moving searching out to user_class_extensions
|
||||
# And then JSON building with something like Active Model Serializers
|
||||
def users
|
||||
if params[:ids]
|
||||
@users = Spree.user_class.where(:id => params[:ids].split(','))
|
||||
else
|
||||
@users = Spree.user_class.ransack({
|
||||
:m => 'or',
|
||||
:email_start => params[:q],
|
||||
:ship_address_firstname_start => params[:q],
|
||||
:ship_address_lastname_start => params[:q],
|
||||
:bill_address_firstname_start => params[:q],
|
||||
:bill_address_lastname_start => params[:q]
|
||||
}).result.limit(10)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user