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