Class: RolesController

Inherits:
ApplicationController show all
Includes:
Foreman::Controller::AutoCompleteSearch
Defined in:
app/controllers/roles_controller.rb

Overview

redMine - project management software Copyright (C) 2006 Jean-Philippe Lang

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

Instance Method Summary collapse

Methods included from Foreman::Controller::AutoCompleteSearch

#auto_complete_search, #invalid_search_query

Methods inherited from ApplicationController

#api_request?, #welcome

Methods included from Foreman::ThreadSession::Cleaner

#clear_thread, included

Instance Method Details

#createObject


35
36
37
38
39
40
41
42
# File 'app/controllers/roles_controller.rb', line 35

def create
  @role = Role.new(params[:role])
  if @role.save
    process_success
  else
    process_error
  end
end

#destroyObject


57
58
59
60
61
62
63
64
# File 'app/controllers/roles_controller.rb', line 57

def destroy
  @role = Role.find(params[:id])
  if @role.destroy
    process_success
  else
    process_error
  end
end

#editObject


44
45
46
# File 'app/controllers/roles_controller.rb', line 44

def edit
  @role = Role.find(params[:id])
end

#indexObject


22
23
24
25
26
27
28
# File 'app/controllers/roles_controller.rb', line 22

def index
  values = Role.search_for(params[:search], :order => params[:order])
  respond_to do |format|
    format.html { @roles = values.paginate :page => params[:page] }
    format.json { render :json => values }
  end
end

#newObject


30
31
32
33
# File 'app/controllers/roles_controller.rb', line 30

def new  # Prefills the form with 'default user' role permissions

  @role        = Role.new({:permissions => Role.default_user.permissions})
end

#reportObject


66
67
68
69
70
71
72
73
74
75
76
77
# File 'app/controllers/roles_controller.rb', line 66

def report
  @roles = Role.all(:order => 'builtin, name')
  @permissions = Foreman::AccessControl.permissions.select { |p| !p.public? }
  if request.post?
    @roles.each do |role|
      role.permissions = params[:permissions][role.id.to_s]
      role.save
    end
    notice _("All non public permissions successfully updated")
    redirect_to roles_url
  end
end

#updateObject


48
49
50
51
52
53
54
55
# File 'app/controllers/roles_controller.rb', line 48

def update
  @role = Role.find(params[:id])
  if @role.update_attributes(params[:role])
    process_success
  else
    process_error
  end
end