##// END OF EJS Templates
When creating a new role, permissions are pre-filled with 'Non member' role permissions....
Jean-Philippe Lang -
r930:aebcfb1eda84
parent child
Show More
@@ -1,111 +1,112
1 1 # redMine - project management software
2 2 # Copyright (C) 2006 Jean-Philippe Lang
3 3 #
4 4 # This program is free software; you can redistribute it and/or
5 5 # modify it under the terms of the GNU General Public License
6 6 # as published by the Free Software Foundation; either version 2
7 7 # of the License, or (at your option) any later version.
8 8 #
9 9 # This program is distributed in the hope that it will be useful,
10 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 12 # GNU General Public License for more details.
13 13 #
14 14 # You should have received a copy of the GNU General Public License
15 15 # along with this program; if not, write to the Free Software
16 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 17
18 18 class RolesController < ApplicationController
19 19 layout 'base'
20 20 before_filter :require_admin
21 21
22 22 verify :method => :post, :only => [ :destroy, :move ],
23 23 :redirect_to => { :action => :list }
24 24
25 25 def index
26 26 list
27 27 render :action => 'list' unless request.xhr?
28 28 end
29 29
30 30 def list
31 31 @role_pages, @roles = paginate :roles, :per_page => 25, :order => 'builtin, position'
32 32 render :action => "list", :layout => false if request.xhr?
33 33 end
34 34
35 35 def new
36 @role = Role.new(params[:role])
36 # Prefills the form with 'Non member' role permissions
37 @role = Role.new(params[:role] || {:permissions => Role.non_member.permissions})
37 38 if request.post? && @role.save
38 39 flash[:notice] = l(:notice_successful_create)
39 40 redirect_to :action => 'list'
40 41 end
41 42 @permissions = @role.setable_permissions
42 43 end
43 44
44 45 def edit
45 46 @role = Role.find(params[:id])
46 47 if request.post? and @role.update_attributes(params[:role])
47 48 flash[:notice] = l(:notice_successful_update)
48 49 redirect_to :action => 'list'
49 50 end
50 51 @permissions = @role.setable_permissions
51 52 end
52 53
53 54 def destroy
54 55 @role = Role.find(params[:id])
55 56 #unless @role.members.empty?
56 57 # flash[:error] = 'Some members have this role. Can\'t delete it.'
57 58 #else
58 59 @role.destroy
59 60 #end
60 61 redirect_to :action => 'list'
61 62 end
62 63
63 64 def move
64 65 @role = Role.find(params[:id])
65 66 case params[:position]
66 67 when 'highest'
67 68 @role.move_to_top
68 69 when 'higher'
69 70 @role.move_higher
70 71 when 'lower'
71 72 @role.move_lower
72 73 when 'lowest'
73 74 @role.move_to_bottom
74 75 end if params[:position]
75 76 redirect_to :action => 'list'
76 77 end
77 78
78 79 def workflow
79 80 @role = Role.find_by_id(params[:role_id])
80 81 @tracker = Tracker.find_by_id(params[:tracker_id])
81 82
82 83 if request.post?
83 84 Workflow.destroy_all( ["role_id=? and tracker_id=?", @role.id, @tracker.id])
84 85 (params[:issue_status] || []).each { |old, news|
85 86 news.each { |new|
86 87 @role.workflows.build(:tracker_id => @tracker.id, :old_status_id => old, :new_status_id => new)
87 88 }
88 89 }
89 90 if @role.save
90 91 flash[:notice] = l(:notice_successful_update)
91 92 redirect_to :action => 'workflow', :role_id => @role, :tracker_id => @tracker
92 93 end
93 94 end
94 95 @roles = Role.find(:all, :order => 'builtin, position')
95 96 @trackers = Tracker.find(:all, :order => 'position')
96 97 @statuses = IssueStatus.find(:all, :include => :workflows, :order => 'position')
97 98 end
98 99
99 100 def report
100 101 @roles = Role.find(:all, :order => 'builtin, position')
101 102 @permissions = Redmine::AccessControl.permissions.select { |p| !p.public? }
102 103 if request.post?
103 104 @roles.each do |role|
104 105 role.permissions = params[:permissions][role.id.to_s]
105 106 role.save
106 107 end
107 108 flash[:notice] = l(:notice_successful_update)
108 109 redirect_to :action => 'list'
109 110 end
110 111 end
111 112 end
General Comments 0
You need to be logged in to leave comments. Login now