Class: Admin::Operations::UsersController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/admin/operations/users_controller.rb

Instance Method Summary collapse

Instance Method Details

#detailsObject



14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'app/controllers/admin/operations/users_controller.rb', line 14

def details
  operation = Operations.user_roles.select{|o| o[:name].to_sym == params[:value].to_sym}.first
  if operation
    operations_list = Operations.operations_for(params[:value].to_sym)
    if operations_list
      render json: {success: true, operations: operations_list.as_json(methods: [:users]), operation: operation.as_json(methods: [:users])}
    else
      render json: {success: false, message: "Operation role `#{params[:value]}' is not valid."}
    end
  else
    render json: {success: false, message: "Operation role `#{params[:value]}' not found."}
  end
end

#indexObject



3
4
5
6
7
8
9
10
11
12
# File 'app/controllers/admin/operations/users_controller.rb', line 3

def index
  @permissions = Operations.user_roles
  respond_to do |format|
    format.html {
      @editing = params[:edit].to_s.downcase.strip == 'true'
      @editing_title = @editing ? 'Manage user permissions' : 'View user permissions'
    }
    format.json { render json: @permissions }
  end
end