Class: Workarea::Admin::UsersController

Inherits:
ApplicationController show all
Includes:
UserParams
Defined in:
app/controllers/workarea/admin/users_controller.rb

Instance Method Summary collapse

Methods included from UserParams

#user_params

Methods inherited from ApplicationController

#current_user, #find_sort, #wrap_in_view_model, wrap_in_view_model

Methods included from Publishing

#allow_publishing!, #allow_publishing?, #set_publishing_options

Methods included from Visiting

#most_visited

Instance Method Details

#addressesObject



54
55
# File 'app/controllers/workarea/admin/users_controller.rb', line 54

def addresses
end

#editObject



33
34
# File 'app/controllers/workarea/admin/users_controller.rb', line 33

def edit
end

#indexObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'app/controllers/workarea/admin/users_controller.rb', line 11

def index
  search_params = params.merge(autocomplete: request.xhr?)

  respond_to do |format|
    format.html do
      search = Search::AdminUsers.new(search_params)
      @search = Admin::UserSearchViewModel.new(search, view_model_options)
    end

    format.json do
      search = Search::AdminUsers.new(search_params.merge(role: ['Administrator']))
      @results =
        Admin::UserSearchViewModel.new(search, view_model_options).results.reject do |result|
          result.id == current_user.id && params[:exclude_current_user]
        end
    end
  end
end

#insightsObject



57
58
59
60
# File 'app/controllers/workarea/admin/users_controller.rb', line 57

def insights
  models = Workarea::Insights::Base.by_customer(@user.email)
  @insights = InsightViewModel.wrap(models, view_model_options)
end

#ordersObject



47
48
# File 'app/controllers/workarea/admin/users_controller.rb', line 47

def orders
end

#permissionsObject



50
51
52
# File 'app/controllers/workarea/admin/users_controller.rb', line 50

def permissions
  unauthorized_user and return unless current_user.permissions_manager?
end

#showObject



30
31
# File 'app/controllers/workarea/admin/users_controller.rb', line 30

def show
end

#updateObject



36
37
38
39
40
41
42
43
44
45
# File 'app/controllers/workarea/admin/users_controller.rb', line 36

def update
  if @user.update_attributes(user_params)
    
    @user.payment_profile.update_attributes(params[:payment])
    flash[:success] = t('workarea.admin.users.flash_messages.saved')
    redirect_to user_path(@user)
  else
    render :edit, status: :unprocessable_entity
  end
end