Class: Spree::Admin::UsersController
Instance Method Summary
collapse
belongs_to, #destroy, #edit, #new, #update_positions
Instance Method Details
#addresses ⇒ Object
51
52
53
54
55
56
57
58
59
|
# File 'app/controllers/spree/admin/users_controller.rb', line 51
def addresses
if request.put?
if @user.update_attributes(user_params)
flash.now[:success] = Spree.t(:account_updated)
end
render :addresses
end
end
|
#clear_api_key ⇒ Object
83
84
85
86
87
88
|
# File 'app/controllers/spree/admin/users_controller.rb', line 83
def clear_api_key
if @user.clear_spree_api_key!
flash[:success] = Spree.t('api.key_cleared')
end
redirect_to edit_admin_user_path(@user)
end
|
#create ⇒ Object
24
25
26
27
28
29
30
31
32
33
34
35
|
# File 'app/controllers/spree/admin/users_controller.rb', line 24
def create
@user = Spree.user_class.new(user_params)
if @user.save
set_roles
flash.now[:success] = flash_message_for(@user, :successfully_created)
render :edit
else
render :new
end
end
|
#generate_api_key ⇒ Object
76
77
78
79
80
81
|
# File 'app/controllers/spree/admin/users_controller.rb', line 76
def generate_api_key
if @user.generate_spree_api_key!
flash[:success] = Spree.t('api.key_generated')
end
redirect_to edit_admin_user_path(@user)
end
|
#index ⇒ Object
13
14
15
16
17
18
|
# File 'app/controllers/spree/admin/users_controller.rb', line 13
def index
respond_with(@collection) do |format|
format.html
format.json { render :json => json_data }
end
end
|
#items ⇒ Object
67
68
69
70
71
72
73
74
|
# File 'app/controllers/spree/admin/users_controller.rb', line 67
def items
params[:q] ||= {}
@search = Spree::Order.includes(
line_items: {
variant: [:product, { option_values: :option_type }]
}).ransack(params[:q].merge(user_id_eq: @user.id))
@orders = @search.result.page(params[:page]).per(Spree::Config[:admin_products_per_page])
end
|
#model_class ⇒ Object
90
91
92
|
# File 'app/controllers/spree/admin/users_controller.rb', line 90
def model_class
Spree.user_class
end
|
#orders ⇒ Object
61
62
63
64
65
|
# File 'app/controllers/spree/admin/users_controller.rb', line 61
def orders
params[:q] ||= {}
@search = Spree::Order.reverse_chronological.ransack(params[:q].merge(user_id_eq: @user.id))
@orders = @search.result.page(params[:page]).per(Spree::Config[:admin_products_per_page])
end
|
#show ⇒ Object
20
21
22
|
# File 'app/controllers/spree/admin/users_controller.rb', line 20
def show
redirect_to edit_admin_user_path(@user)
end
|
#update ⇒ Object
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# File 'app/controllers/spree/admin/users_controller.rb', line 37
def update
if params[:user][:password].blank? && params[:user][:password_confirmation].blank?
params[:user].delete(:password)
params[:user].delete(:password_confirmation)
end
if @user.update_attributes(user_params)
set_roles
flash.now[:success] = Spree.t(:account_updated)
end
render :edit
end
|