diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2011-12-09 23:29:58 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2011-12-09 23:29:58 +0000 |
commit | 532a76f78c917d4391f4a8ecce9f8201b041d57d (patch) | |
tree | 184c676eaf6f1a867ac47197f5722a272d76858b /app/controllers/roles_controller.rb | |
parent | b127f9157d456f233b320b349b415844eb632cb9 (diff) | |
download | redmine-532a76f78c917d4391f4a8ecce9f8201b041d57d.tar.gz redmine-532a76f78c917d4391f4a8ecce9f8201b041d57d.zip |
Resourcified roles.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8145 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/controllers/roles_controller.rb')
-rw-r--r-- | app/controllers/roles_controller.rb | 32 |
1 files changed, 23 insertions, 9 deletions
diff --git a/app/controllers/roles_controller.rb b/app/controllers/roles_controller.rb index c0713cb82..b74404470 100644 --- a/app/controllers/roles_controller.rb +++ b/app/controllers/roles_controller.rb @@ -19,9 +19,8 @@ class RolesController < ApplicationController layout 'admin' before_filter :require_admin + before_filter :find_role, :only => [:edit, :update, :destroy] - verify :method => :post, :only => [ :destroy ], - :redirect_to => { :action => :index } def index @role_pages, @roles = paginate :roles, :per_page => 25, :order => 'builtin, position' @@ -31,6 +30,11 @@ class RolesController < ApplicationController def new # Prefills the form with 'Non member' role permissions @role = Role.new(params[:role] || {:permissions => Role.non_member.permissions}) + @roles = Role.all + end + + def create + @role = Role.new(params[:role]) if request.post? && @role.save # workflow copy if !params[:copy_workflow_from].blank? && (copy_from = Role.find_by_id(params[:copy_workflow_from])) @@ -39,23 +43,25 @@ class RolesController < ApplicationController flash[:notice] = l(:notice_successful_create) redirect_to :action => 'index' else - @permissions = @role.setable_permissions - @roles = Role.find :all, :order => 'builtin, position' + @roles = Role.all + render :action => 'new' end end def edit - @role = Role.find(params[:id]) - if request.post? and @role.update_attributes(params[:role]) + end + + def update + if request.put? and @role.update_attributes(params[:role]) flash[:notice] = l(:notice_successful_update) redirect_to :action => 'index' else - @permissions = @role.setable_permissions + render :action => 'edit' end end + verify :method => :delete, :only => :destroy, :redirect_to => { :action => :index } def destroy - @role = Role.find(params[:id]) @role.destroy redirect_to :action => 'index' rescue @@ -63,7 +69,7 @@ class RolesController < ApplicationController redirect_to :action => 'index' end - def report + def permissions @roles = Role.find(:all, :order => 'builtin, position') @permissions = Redmine::AccessControl.permissions.select { |p| !p.public? } if request.post? @@ -75,4 +81,12 @@ class RolesController < ApplicationController redirect_to :action => 'index' end end + + private + + def find_role + @role = Role.find(params[:id]) + rescue ActiveRecord::RecordNotFound + render_404 + end end |