##// END OF EJS Templates
indentation corrections...
Jean-Philippe Lang -
r198:99c560295fca
parent child
Show More
@@ -1,44 +1,44
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 IssueCategoriesController < ApplicationController
19 layout 'base'
20 before_filter :find_project, :authorize
21
19 layout 'base'
20 before_filter :find_project, :authorize
21
22 22 def edit
23 23 if request.post? and @category.update_attributes(params[:category])
24 24 flash[:notice] = l(:notice_successful_update)
25 25 redirect_to :controller => 'projects', :action => 'settings', :tab => 'categories', :id => @project
26 26 end
27 27 end
28 28
29 29 def destroy
30 30 @category.destroy
31 31 redirect_to :controller => 'projects', :action => 'settings', :tab => 'categories', :id => @project
32 32 rescue
33 33 flash[:notice] = "Categorie can't be deleted"
34 34 redirect_to :controller => 'projects', :action => 'settings', :tab => 'categories', :id => @project
35 35 end
36 36
37 37 private
38 38 def find_project
39 39 @category = IssueCategory.find(params[:id])
40 40 @project = @category.project
41 41 rescue ActiveRecord::RecordNotFound
42 42 render_404
43 43 end
44 44 end
@@ -1,69 +1,67
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 IssueStatusesController < ApplicationController
19 layout 'base'
20 before_filter :require_admin
21
19 layout 'base'
20 before_filter :require_admin
21
22 22 def index
23 23 list
24 24 render :action => 'list' unless request.xhr?
25 25 end
26 26
27 27 def list
28 28 @issue_status_pages, @issue_statuses = paginate :issue_statuses, :per_page => 10
29 29 render :action => "list", :layout => false if request.xhr?
30 30 end
31 31
32 32 def new
33 33 @issue_status = IssueStatus.new
34 34 end
35 35
36 36 def create
37 37 @issue_status = IssueStatus.new(params[:issue_status])
38 38 if @issue_status.save
39 39 flash[:notice] = l(:notice_successful_create)
40 40 redirect_to :action => 'list'
41 41 else
42 42 render :action => 'new'
43 43 end
44 44 end
45 45
46 46 def edit
47 47 @issue_status = IssueStatus.find(params[:id])
48 48 end
49 49
50 50 def update
51 51 @issue_status = IssueStatus.find(params[:id])
52 52 if @issue_status.update_attributes(params[:issue_status])
53 53 flash[:notice] = l(:notice_successful_update)
54 54 redirect_to :action => 'list'
55 55 else
56 56 render :action => 'edit'
57 57 end
58 58 end
59 59
60 60 def destroy
61 61 IssueStatus.find(params[:id]).destroy
62 62 redirect_to :action => 'list'
63 63 rescue
64 64 flash[:notice] = "Unable to delete issue status"
65 65 redirect_to :action => 'list'
66 end
67
68
66 end
69 67 end
@@ -1,43 +1,42
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 MembersController < ApplicationController
19 19 layout 'base'
20 20 before_filter :find_project, :authorize
21 21
22 22 def edit
23 23 if request.post? and @member.update_attributes(params[:member])
24 24 flash[:notice] = l(:notice_successful_update)
25 25 redirect_to :controller => 'projects', :action => 'settings', :tab => 'members', :id => @project
26 26 end
27 27 end
28 28
29 29 def destroy
30 30 @member.destroy
31 31 flash[:notice] = l(:notice_successful_delete)
32 32 redirect_to :controller => 'projects', :action => 'settings', :tab => 'members', :id => @project
33 33 end
34 34
35 35 private
36 36 def find_project
37 37 @member = Member.find(params[:id])
38 38 @project = @member.project
39 39 rescue ActiveRecord::RecordNotFound
40 40 render_404
41 end
42
41 end
43 42 end
@@ -1,60 +1,60
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 NewsController < ApplicationController
19 layout 'base'
20 before_filter :find_project, :authorize
19 layout 'base'
20 before_filter :find_project, :authorize
21 21
22 22 def show
23 23 end
24 24
25 25 def edit
26 26 if request.post? and @news.update_attributes(params[:news])
27 27 flash[:notice] = l(:notice_successful_update)
28 28 redirect_to :action => 'show', :id => @news
29 29 end
30 30 end
31 31
32 32 def add_comment
33 33 @comment = Comment.new(params[:comment])
34 34 @comment.author = logged_in_user
35 35 if @news.comments << @comment
36 36 flash[:notice] = l(:label_comment_added)
37 37 redirect_to :action => 'show', :id => @news
38 38 else
39 39 render :action => 'show'
40 40 end
41 41 end
42 42
43 43 def destroy_comment
44 44 @news.comments.find(params[:comment_id]).destroy
45 45 redirect_to :action => 'show', :id => @news
46 46 end
47 47
48 def destroy
49 @news.destroy
50 redirect_to :controller => 'projects', :action => 'list_news', :id => @project
51 end
48 def destroy
49 @news.destroy
50 redirect_to :controller => 'projects', :action => 'list_news', :id => @project
51 end
52 52
53 53 private
54 54 def find_project
55 55 @news = News.find(params[:id])
56 56 @project = @news.project
57 57 rescue ActiveRecord::RecordNotFound
58 58 render_404
59 59 end
60 60 end
@@ -1,167 +1,167
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 ReportsController < ApplicationController
19 layout 'base'
20 before_filter :find_project, :authorize
21
19 layout 'base'
20 before_filter :find_project, :authorize
21
22 22 def issue_report
23 23 @statuses = IssueStatus.find :all
24 24
25 25 case params[:detail]
26 26 when "tracker"
27 27 @field = "tracker_id"
28 28 @rows = Tracker.find :all
29 29 @data = issues_by_tracker
30 30 @report_title = l(:field_tracker)
31 31 render :template => "reports/issue_report_details"
32 32 when "priority"
33 33 @field = "priority_id"
34 34 @rows = Enumeration::get_values('IPRI')
35 35 @data = issues_by_priority
36 36 @report_title = l(:field_priority)
37 37 render :template => "reports/issue_report_details"
38 38 when "category"
39 39 @field = "category_id"
40 40 @rows = @project.issue_categories
41 41 @data = issues_by_category
42 42 @report_title = l(:field_category)
43 43 render :template => "reports/issue_report_details"
44 44 when "author"
45 45 @field = "author_id"
46 46 @rows = @project.members.collect { |m| m.user }
47 47 @data = issues_by_author
48 48 @report_title = l(:field_author)
49 49 render :template => "reports/issue_report_details"
50 50 else
51 51 @queries = @project.queries.find :all, :conditions => ["is_public=? or user_id=?", true, (logged_in_user ? logged_in_user.id : 0)]
52 52 @trackers = Tracker.find(:all)
53 53 @priorities = Enumeration::get_values('IPRI')
54 54 @categories = @project.issue_categories
55 55 @authors = @project.members.collect { |m| m.user }
56 56 issues_by_tracker
57 57 issues_by_priority
58 58 issues_by_category
59 59 issues_by_author
60 60 render :template => "reports/issue_report"
61 61 end
62 62 end
63 63
64 64 def delays
65 65 @trackers = Tracker.find(:all)
66 66 if request.get?
67 67 @selected_tracker_ids = @trackers.collect {|t| t.id.to_s }
68 68 else
69 69 @selected_tracker_ids = params[:tracker_ids].collect { |id| id.to_i.to_s } if params[:tracker_ids] and params[:tracker_ids].is_a? Array
70 70 end
71 71 @selected_tracker_ids ||= []
72 72 @raw =
73 73 ActiveRecord::Base.connection.select_all("SELECT datediff( a.created_on, b.created_on ) as delay, count(a.id) as total
74 74 FROM issue_histories a, issue_histories b, issues i
75 75 WHERE a.status_id =5
76 76 AND a.issue_id = b.issue_id
77 77 AND a.issue_id = i.id
78 78 AND i.tracker_id in (#{@selected_tracker_ids.join(',')})
79 79 AND b.id = (
80 80 SELECT min( c.id )
81 81 FROM issue_histories c
82 82 WHERE b.issue_id = c.issue_id )
83 83 GROUP BY delay") unless @selected_tracker_ids.empty?
84 84 @raw ||=[]
85 85
86 86 @x_from = 0
87 87 @x_to = 0
88 88 @y_from = 0
89 89 @y_to = 0
90 90 @sum_total = 0
91 91 @sum_delay = 0
92 92 @raw.each do |r|
93 93 @x_to = [r['delay'].to_i, @x_to].max
94 94 @y_to = [r['total'].to_i, @y_to].max
95 95 @sum_total = @sum_total + r['total'].to_i
96 96 @sum_delay = @sum_delay + r['total'].to_i * r['delay'].to_i
97 97 end
98 98 end
99 99
100 100 private
101 101 # Find project of id params[:id]
102 102 def find_project
103 103 @project = Project.find(params[:id])
104 104 rescue ActiveRecord::RecordNotFound
105 105 render_404
106 106 end
107
108 def issues_by_tracker
107
108 def issues_by_tracker
109 109 @issues_by_tracker ||=
110 110 ActiveRecord::Base.connection.select_all("select s.id as status_id,
111 111 s.is_closed as closed,
112 112 t.id as tracker_id,
113 113 count(i.id) as total
114 114 from
115 115 issues i, issue_statuses s, trackers t
116 116 where
117 117 i.status_id=s.id
118 118 and i.tracker_id=t.id
119 119 and i.project_id=#{@project.id}
120 120 group by s.id, s.is_closed, t.id")
121 end
121 end
122 122
123 def issues_by_priority
123 def issues_by_priority
124 124 @issues_by_priority ||=
125 125 ActiveRecord::Base.connection.select_all("select s.id as status_id,
126 126 s.is_closed as closed,
127 127 p.id as priority_id,
128 128 count(i.id) as total
129 129 from
130 130 issues i, issue_statuses s, enumerations p
131 131 where
132 132 i.status_id=s.id
133 133 and i.priority_id=p.id
134 134 and i.project_id=#{@project.id}
135 135 group by s.id, s.is_closed, p.id")
136 end
136 end
137 137
138 def issues_by_category
138 def issues_by_category
139 139 @issues_by_category ||=
140 140 ActiveRecord::Base.connection.select_all("select s.id as status_id,
141 141 s.is_closed as closed,
142 142 c.id as category_id,
143 143 count(i.id) as total
144 144 from
145 145 issues i, issue_statuses s, issue_categories c
146 146 where
147 147 i.status_id=s.id
148 148 and i.category_id=c.id
149 149 and i.project_id=#{@project.id}
150 150 group by s.id, s.is_closed, c.id")
151 end
151 end
152 152
153 def issues_by_author
153 def issues_by_author
154 154 @issues_by_author ||=
155 155 ActiveRecord::Base.connection.select_all("select s.id as status_id,
156 156 s.is_closed as closed,
157 157 a.id as author_id,
158 158 count(i.id) as total
159 159 from
160 160 issues i, issue_statuses s, users a
161 161 where
162 162 i.status_id=s.id
163 163 and i.author_id=a.id
164 164 and i.project_id=#{@project.id}
165 165 group by s.id, s.is_closed, a.id")
166 end
166 end
167 167 end
@@ -1,84 +1,84
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 layout 'base'
20 before_filter :require_admin
21
19 layout 'base'
20 before_filter :require_admin
21
22 22 def index
23 23 list
24 24 render :action => 'list' unless request.xhr?
25 25 end
26 26
27 27 def list
28 28 @role_pages, @roles = paginate :roles, :per_page => 10
29 29 render :action => "list", :layout => false if request.xhr?
30 30 end
31 31
32 32 def new
33 33 @role = Role.new(params[:role])
34 34 if request.post?
35 35 @role.permissions = Permission.find(params[:permission_ids]) if params[:permission_ids]
36 36 if @role.save
37 37 flash[:notice] = l(:notice_successful_create)
38 38 redirect_to :action => 'list'
39 39 end
40 40 end
41 41 @permissions = Permission.find(:all, :conditions => ["is_public=?", false], :order => 'sort ASC')
42 42 end
43 43
44 44 def edit
45 45 @role = Role.find(params[:id])
46 46 if request.post? and @role.update_attributes(params[:role])
47 47 @role.permissions = Permission.find(params[:permission_ids] || [])
48 48 Permission.allowed_to_role_expired
49 49 flash[:notice] = l(:notice_successful_update)
50 50 redirect_to :action => 'list'
51 51 end
52 52 @permissions = Permission.find(:all, :conditions => ["is_public=?", false], :order => 'sort ASC')
53 53 end
54 54
55 55 def destroy
56 56 @role = Role.find(params[:id])
57 57 unless @role.members.empty?
58 58 flash[:notice] = 'Some members have this role. Can\'t delete it.'
59 59 else
60 60 @role.destroy
61 61 end
62 62 redirect_to :action => 'list'
63 63 end
64 64
65 65 def workflow
66 66 @role = Role.find_by_id(params[:role_id])
67 67 @tracker = Tracker.find_by_id(params[:tracker_id])
68 68
69 69 if request.post?
70 70 Workflow.destroy_all( ["role_id=? and tracker_id=?", @role.id, @tracker.id])
71 71 (params[:issue_status] || []).each { |old, news|
72 72 news.each { |new|
73 73 @role.workflows.build(:tracker_id => @tracker.id, :old_status_id => old, :new_status_id => new)
74 74 }
75 75 }
76 76 if @role.save
77 77 flash[:notice] = l(:notice_successful_update)
78 78 end
79 79 end
80 80 @roles = Role.find :all
81 81 @trackers = Tracker.find :all
82 82 @statuses = IssueStatus.find(:all, :include => :workflows)
83 83 end
84 84 end
@@ -1,61 +1,60
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 TrackersController < ApplicationController
19 19 layout 'base'
20 20 before_filter :require_admin
21 21
22 22 def index
23 23 list
24 24 render :action => 'list' unless request.xhr?
25 25 end
26 26
27 27 # GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html)
28 28 verify :method => :post, :only => [ :destroy ], :redirect_to => { :action => :list }
29 29
30 30 def list
31 31 @tracker_pages, @trackers = paginate :trackers, :per_page => 10
32 32 render :action => "list", :layout => false if request.xhr?
33 33 end
34 34
35 35 def new
36 36 @tracker = Tracker.new(params[:tracker])
37 37 if request.post? and @tracker.save
38 38 flash[:notice] = l(:notice_successful_create)
39 39 redirect_to :action => 'list'
40 40 end
41 41 end
42 42
43 43 def edit
44 44 @tracker = Tracker.find(params[:id])
45 45 if request.post? and @tracker.update_attributes(params[:tracker])
46 46 flash[:notice] = l(:notice_successful_update)
47 47 redirect_to :action => 'list'
48 48 end
49 49 end
50 50
51 51 def destroy
52 52 @tracker = Tracker.find(params[:id])
53 53 unless @tracker.issues.empty?
54 54 flash[:notice] = "This tracker contains issues and can\'t be deleted."
55 55 else
56 56 @tracker.destroy
57 57 end
58 58 redirect_to :action => 'list'
59 end
60
59 end
61 60 end
General Comments 0
You need to be logged in to leave comments. Login now