@@ -1,391 +1,391 | |||
|
1 | 1 | # redMine - project management software |
|
2 | 2 | # Copyright (C) 2006-2007 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 ProjectsController < ApplicationController |
|
19 | 19 | layout 'base' |
|
20 | 20 | menu_item :overview |
|
21 | 21 | menu_item :activity, :only => :activity |
|
22 | 22 | menu_item :roadmap, :only => :roadmap |
|
23 | 23 | menu_item :files, :only => [:list_files, :add_file] |
|
24 | 24 | menu_item :settings, :only => :settings |
|
25 | 25 | menu_item :issues, :only => [:changelog] |
|
26 | 26 | |
|
27 | 27 | before_filter :find_project, :except => [ :index, :list, :add ] |
|
28 | 28 | before_filter :authorize, :except => [ :index, :list, :add, :archive, :unarchive, :destroy ] |
|
29 | 29 | before_filter :require_admin, :only => [ :add, :archive, :unarchive, :destroy ] |
|
30 | 30 | accept_key_auth :activity, :calendar |
|
31 | 31 | |
|
32 | 32 | helper :sort |
|
33 | 33 | include SortHelper |
|
34 | 34 | helper :custom_fields |
|
35 | 35 | include CustomFieldsHelper |
|
36 | 36 | helper :ifpdf |
|
37 | 37 | include IfpdfHelper |
|
38 | 38 | helper :issues |
|
39 | 39 | helper IssuesHelper |
|
40 | 40 | helper :queries |
|
41 | 41 | include QueriesHelper |
|
42 | 42 | helper :repositories |
|
43 | 43 | include RepositoriesHelper |
|
44 | 44 | include ProjectsHelper |
|
45 | 45 | |
|
46 | 46 | def index |
|
47 | 47 | list |
|
48 | 48 | render :action => 'list' unless request.xhr? |
|
49 | 49 | end |
|
50 | 50 | |
|
51 | 51 | # Lists visible projects |
|
52 | 52 | def list |
|
53 | 53 | projects = Project.find :all, |
|
54 | 54 | :conditions => Project.visible_by(User.current), |
|
55 | 55 | :include => :parent |
|
56 | 56 | @project_tree = projects.group_by {|p| p.parent || p} |
|
57 | 57 | @project_tree.each_key {|p| @project_tree[p] -= [p]} |
|
58 | 58 | end |
|
59 | 59 | |
|
60 | 60 | # Add a new project |
|
61 | 61 | def add |
|
62 | 62 | @custom_fields = IssueCustomField.find(:all, :order => "#{CustomField.table_name}.position") |
|
63 | 63 | @trackers = Tracker.all |
|
64 | 64 | @root_projects = Project.find(:all, |
|
65 | 65 | :conditions => "parent_id IS NULL AND status = #{Project::STATUS_ACTIVE}", |
|
66 | 66 | :order => 'name') |
|
67 | 67 | @project = Project.new(params[:project]) |
|
68 | 68 | @project.enabled_module_names = Redmine::AccessControl.available_project_modules |
|
69 | 69 | if request.get? |
|
70 | 70 | @custom_values = ProjectCustomField.find(:all, :order => "#{CustomField.table_name}.position").collect { |x| CustomValue.new(:custom_field => x, :customized => @project) } |
|
71 | 71 | @project.trackers = Tracker.all |
|
72 | 72 | else |
|
73 | 73 | @project.custom_fields = CustomField.find(params[:custom_field_ids]) if params[:custom_field_ids] |
|
74 | 74 | @custom_values = ProjectCustomField.find(:all, :order => "#{CustomField.table_name}.position").collect { |x| CustomValue.new(:custom_field => x, :customized => @project, :value => (params[:custom_fields] ? params["custom_fields"][x.id.to_s] : nil)) } |
|
75 | 75 | @project.custom_values = @custom_values |
|
76 | 76 | if @project.save |
|
77 | 77 | @project.enabled_module_names = params[:enabled_modules] |
|
78 | 78 | flash[:notice] = l(:notice_successful_create) |
|
79 | 79 | redirect_to :controller => 'admin', :action => 'projects' |
|
80 | 80 | end |
|
81 | 81 | end |
|
82 | 82 | end |
|
83 | 83 | |
|
84 | 84 | # Show @project |
|
85 | 85 | def show |
|
86 | 86 | @custom_values = @project.custom_values.find(:all, :include => :custom_field, :order => "#{CustomField.table_name}.position") |
|
87 | 87 | @members_by_role = @project.members.find(:all, :include => [:user, :role], :order => 'position').group_by {|m| m.role} |
|
88 | 88 | @subprojects = @project.active_children |
|
89 | 89 | @news = @project.news.find(:all, :limit => 5, :include => [ :author, :project ], :order => "#{News.table_name}.created_on DESC") |
|
90 | 90 | @trackers = @project.rolled_up_trackers |
|
91 | 91 | Issue.visible_by(User.current) do |
|
92 | 92 | @open_issues_by_tracker = Issue.count(:group => :tracker, |
|
93 | 93 | :include => [:project, :status, :tracker], |
|
94 | 94 | :conditions => ["(#{Project.table_name}.id=? OR #{Project.table_name}.parent_id=?) and #{IssueStatus.table_name}.is_closed=?", @project.id, @project.id, false]) |
|
95 | 95 | @total_issues_by_tracker = Issue.count(:group => :tracker, |
|
96 | 96 | :include => [:project, :status, :tracker], |
|
97 | 97 | :conditions => ["#{Project.table_name}.id=? OR #{Project.table_name}.parent_id=?", @project.id, @project.id]) |
|
98 | 98 | end |
|
99 | 99 | TimeEntry.visible_by(User.current) do |
|
100 | 100 | @total_hours = TimeEntry.sum(:hours, |
|
101 | 101 | :include => :project, |
|
102 | 102 | :conditions => ["(#{Project.table_name}.id = ? OR #{Project.table_name}.parent_id = ?)", @project.id, @project.id]).to_f |
|
103 | 103 | end |
|
104 | 104 | @key = User.current.rss_key |
|
105 | 105 | end |
|
106 | 106 | |
|
107 | 107 | def settings |
|
108 | 108 | @root_projects = Project.find(:all, |
|
109 | 109 | :conditions => ["parent_id IS NULL AND status = #{Project::STATUS_ACTIVE} AND id <> ?", @project.id], |
|
110 | 110 | :order => 'name') |
|
111 | 111 | @custom_fields = IssueCustomField.find(:all) |
|
112 | 112 | @issue_category ||= IssueCategory.new |
|
113 | 113 | @member ||= @project.members.new |
|
114 | 114 | @trackers = Tracker.all |
|
115 | 115 | @custom_values ||= ProjectCustomField.find(:all, :order => "#{CustomField.table_name}.position").collect { |x| @project.custom_values.find_by_custom_field_id(x.id) || CustomValue.new(:custom_field => x) } |
|
116 | 116 | @repository ||= @project.repository |
|
117 | 117 | @wiki ||= @project.wiki |
|
118 | 118 | end |
|
119 | 119 | |
|
120 | 120 | # Edit @project |
|
121 | 121 | def edit |
|
122 | 122 | if request.post? |
|
123 | 123 | if params[:custom_fields] |
|
124 | 124 | @custom_values = ProjectCustomField.find(:all, :order => "#{CustomField.table_name}.position").collect { |x| CustomValue.new(:custom_field => x, :customized => @project, :value => params["custom_fields"][x.id.to_s]) } |
|
125 | 125 | @project.custom_values = @custom_values |
|
126 | 126 | end |
|
127 | 127 | @project.attributes = params[:project] |
|
128 | 128 | if @project.save |
|
129 | 129 | flash[:notice] = l(:notice_successful_update) |
|
130 | 130 | redirect_to :action => 'settings', :id => @project |
|
131 | 131 | else |
|
132 | 132 | settings |
|
133 | 133 | render :action => 'settings' |
|
134 | 134 | end |
|
135 | 135 | end |
|
136 | 136 | end |
|
137 | 137 | |
|
138 | 138 | def modules |
|
139 | 139 | @project.enabled_module_names = params[:enabled_modules] |
|
140 | 140 | redirect_to :action => 'settings', :id => @project, :tab => 'modules' |
|
141 | 141 | end |
|
142 | 142 | |
|
143 | 143 | def archive |
|
144 | 144 | @project.archive if request.post? && @project.active? |
|
145 | 145 | redirect_to :controller => 'admin', :action => 'projects' |
|
146 | 146 | end |
|
147 | 147 | |
|
148 | 148 | def unarchive |
|
149 | 149 | @project.unarchive if request.post? && !@project.active? |
|
150 | 150 | redirect_to :controller => 'admin', :action => 'projects' |
|
151 | 151 | end |
|
152 | 152 | |
|
153 | 153 | # Delete @project |
|
154 | 154 | def destroy |
|
155 | 155 | @project_to_destroy = @project |
|
156 | 156 | if request.post? and params[:confirm] |
|
157 | 157 | @project_to_destroy.destroy |
|
158 | 158 | redirect_to :controller => 'admin', :action => 'projects' |
|
159 | 159 | end |
|
160 | 160 | # hide project in layout |
|
161 | 161 | @project = nil |
|
162 | 162 | end |
|
163 | 163 | |
|
164 | 164 | # Add a new issue category to @project |
|
165 | 165 | def add_issue_category |
|
166 | 166 | @category = @project.issue_categories.build(params[:category]) |
|
167 | 167 | if request.post? and @category.save |
|
168 | 168 | respond_to do |format| |
|
169 | 169 | format.html do |
|
170 | 170 | flash[:notice] = l(:notice_successful_create) |
|
171 | 171 | redirect_to :action => 'settings', :tab => 'categories', :id => @project |
|
172 | 172 | end |
|
173 | 173 | format.js do |
|
174 | 174 | # IE doesn't support the replace_html rjs method for select box options |
|
175 | 175 | render(:update) {|page| page.replace "issue_category_id", |
|
176 | 176 | content_tag('select', '<option></option>' + options_from_collection_for_select(@project.issue_categories, 'id', 'name', @category.id), :id => 'issue_category_id', :name => 'issue[category_id]') |
|
177 | 177 | } |
|
178 | 178 | end |
|
179 | 179 | end |
|
180 | 180 | end |
|
181 | 181 | end |
|
182 | 182 | |
|
183 | 183 | # Add a new version to @project |
|
184 | 184 | def add_version |
|
185 | 185 | @version = @project.versions.build(params[:version]) |
|
186 | 186 | if request.post? and @version.save |
|
187 | 187 | flash[:notice] = l(:notice_successful_create) |
|
188 | 188 | redirect_to :action => 'settings', :tab => 'versions', :id => @project |
|
189 | 189 | end |
|
190 | 190 | end |
|
191 | 191 | |
|
192 | 192 | def add_file |
|
193 | 193 | if request.post? |
|
194 | 194 | @version = @project.versions.find_by_id(params[:version_id]) |
|
195 | 195 | attachments = attach_files(@version, params[:attachments]) |
|
196 | 196 | Mailer.deliver_attachments_added(attachments) if !attachments.empty? && Setting.notified_events.include?('file_added') |
|
197 | 197 | redirect_to :controller => 'projects', :action => 'list_files', :id => @project |
|
198 | 198 | end |
|
199 | 199 | @versions = @project.versions.sort |
|
200 | 200 | end |
|
201 | 201 | |
|
202 | 202 | def list_files |
|
203 | 203 | @versions = @project.versions.sort.reverse |
|
204 | 204 | end |
|
205 | 205 | |
|
206 | 206 | # Show changelog for @project |
|
207 | 207 | def changelog |
|
208 | 208 | @trackers = @project.trackers.find(:all, :conditions => ["is_in_chlog=?", true], :order => 'position') |
|
209 | 209 | retrieve_selected_tracker_ids(@trackers) |
|
210 | 210 | @versions = @project.versions.sort |
|
211 | 211 | end |
|
212 | 212 | |
|
213 | 213 | def roadmap |
|
214 | 214 | @trackers = @project.trackers.find(:all, :conditions => ["is_in_roadmap=?", true]) |
|
215 | 215 | retrieve_selected_tracker_ids(@trackers) |
|
216 | 216 | @versions = @project.versions.sort |
|
217 | 217 | @versions = @versions.select {|v| !v.completed? } unless params[:completed] |
|
218 | 218 | end |
|
219 | 219 | |
|
220 | 220 | def activity |
|
221 | 221 | @days = Setting.activity_days_default.to_i |
|
222 | 222 | |
|
223 | 223 | if params[:from] |
|
224 | 224 | begin; @date_to = params[:from].to_date; rescue; end |
|
225 | 225 | end |
|
226 | 226 | |
|
227 | 227 | @date_to ||= Date.today + 1 |
|
228 | 228 | @date_from = @date_to - @days |
|
229 | 229 | |
|
230 | 230 | @event_types = %w(issues news files documents changesets wiki_pages messages) |
|
231 | 231 | @event_types.delete('wiki_pages') unless @project.wiki |
|
232 | 232 | @event_types.delete('changesets') unless @project.repository |
|
233 | 233 | @event_types.delete('messages') unless @project.boards.any? |
|
234 | 234 | # only show what the user is allowed to view |
|
235 | 235 | @event_types = @event_types.select {|o| User.current.allowed_to?("view_#{o}".to_sym, @project)} |
|
236 | 236 | |
|
237 | 237 | @scope = @event_types.select {|t| params["show_#{t}"]} |
|
238 | 238 | # default events if none is specified in parameters |
|
239 | 239 | @scope = (@event_types - %w(wiki_pages messages))if @scope.empty? |
|
240 | 240 | |
|
241 | 241 | @events = [] |
|
242 | 242 | |
|
243 | 243 | if @scope.include?('issues') |
|
244 | 244 | @events += @project.issues.find(:all, :include => [:author, :tracker], :conditions => ["#{Issue.table_name}.created_on>=? and #{Issue.table_name}.created_on<=?", @date_from, @date_to] ) |
|
245 | 245 | @events += @project.issues_status_changes(@date_from, @date_to) |
|
246 | 246 | end |
|
247 | 247 | |
|
248 | 248 | if @scope.include?('news') |
|
249 | 249 | @events += @project.news.find(:all, :conditions => ["#{News.table_name}.created_on>=? and #{News.table_name}.created_on<=?", @date_from, @date_to], :include => :author ) |
|
250 | 250 | end |
|
251 | 251 | |
|
252 | 252 | if @scope.include?('files') |
|
253 | 253 | @events += Attachment.find(:all, :select => "#{Attachment.table_name}.*", :joins => "LEFT JOIN #{Version.table_name} ON #{Version.table_name}.id = #{Attachment.table_name}.container_id", :conditions => ["#{Attachment.table_name}.container_type='Version' and #{Version.table_name}.project_id=? and #{Attachment.table_name}.created_on>=? and #{Attachment.table_name}.created_on<=?", @project.id, @date_from, @date_to], :include => :author ) |
|
254 | 254 | end |
|
255 | 255 | |
|
256 | 256 | if @scope.include?('documents') |
|
257 | 257 | @events += @project.documents.find(:all, :conditions => ["#{Document.table_name}.created_on>=? and #{Document.table_name}.created_on<=?", @date_from, @date_to] ) |
|
258 | 258 | @events += Attachment.find(:all, :select => "attachments.*", :joins => "LEFT JOIN #{Document.table_name} ON #{Document.table_name}.id = #{Attachment.table_name}.container_id", :conditions => ["#{Attachment.table_name}.container_type='Document' and #{Document.table_name}.project_id=? and #{Attachment.table_name}.created_on>=? and #{Attachment.table_name}.created_on<=?", @project.id, @date_from, @date_to], :include => :author ) |
|
259 | 259 | end |
|
260 | 260 | |
|
261 | 261 | if @scope.include?('wiki_pages') |
|
262 | 262 | select = "#{WikiContent.versioned_table_name}.updated_on, #{WikiContent.versioned_table_name}.comments, " + |
|
263 | 263 | "#{WikiContent.versioned_table_name}.#{WikiContent.version_column}, #{WikiPage.table_name}.title, " + |
|
264 | 264 | "#{WikiContent.versioned_table_name}.page_id, #{WikiContent.versioned_table_name}.author_id, " + |
|
265 | 265 | "#{WikiContent.versioned_table_name}.id" |
|
266 | 266 | joins = "LEFT JOIN #{WikiPage.table_name} ON #{WikiPage.table_name}.id = #{WikiContent.versioned_table_name}.page_id " + |
|
267 | 267 | "LEFT JOIN #{Wiki.table_name} ON #{Wiki.table_name}.id = #{WikiPage.table_name}.wiki_id " |
|
268 | 268 | conditions = ["#{Wiki.table_name}.project_id = ? AND #{WikiContent.versioned_table_name}.updated_on BETWEEN ? AND ?", |
|
269 | 269 | @project.id, @date_from, @date_to] |
|
270 | 270 | |
|
271 | 271 | @events += WikiContent.versioned_class.find(:all, :select => select, :joins => joins, :conditions => conditions) |
|
272 | 272 | end |
|
273 | 273 | |
|
274 | 274 | if @scope.include?('changesets') |
|
275 | 275 | @events += Changeset.find(:all, :include => :repository, :conditions => ["#{Repository.table_name}.project_id = ? AND #{Changeset.table_name}.committed_on BETWEEN ? AND ?", @project.id, @date_from, @date_to]) |
|
276 | 276 | end |
|
277 | 277 | |
|
278 | 278 | if @scope.include?('messages') |
|
279 | 279 | @events += Message.find(:all, |
|
280 | 280 | :include => [:board, :author], |
|
281 |
:conditions => ["#{Board.table_name}.project_id=? AND |
|
|
281 | :conditions => ["#{Board.table_name}.project_id=? AND #{Message.table_name}.created_on BETWEEN ? AND ?", @project.id, @date_from, @date_to]) | |
|
282 | 282 | end |
|
283 | 283 | |
|
284 | 284 | @events_by_day = @events.group_by(&:event_date) |
|
285 | 285 | |
|
286 | 286 | respond_to do |format| |
|
287 | 287 | format.html { render :layout => false if request.xhr? } |
|
288 | 288 | format.atom { render_feed(@events, :title => "#{@project.name}: #{l(:label_activity)}") } |
|
289 | 289 | end |
|
290 | 290 | end |
|
291 | 291 | |
|
292 | 292 | def calendar |
|
293 | 293 | @trackers = @project.rolled_up_trackers |
|
294 | 294 | retrieve_selected_tracker_ids(@trackers) |
|
295 | 295 | |
|
296 | 296 | if params[:year] and params[:year].to_i > 1900 |
|
297 | 297 | @year = params[:year].to_i |
|
298 | 298 | if params[:month] and params[:month].to_i > 0 and params[:month].to_i < 13 |
|
299 | 299 | @month = params[:month].to_i |
|
300 | 300 | end |
|
301 | 301 | end |
|
302 | 302 | @year ||= Date.today.year |
|
303 | 303 | @month ||= Date.today.month |
|
304 | 304 | @calendar = Redmine::Helpers::Calendar.new(Date.civil(@year, @month, 1), current_language, :month) |
|
305 | 305 | @with_subprojects = params[:with_subprojects].nil? ? Setting.display_subprojects_issues? : (params[:with_subprojects] == '1') |
|
306 | 306 | events = [] |
|
307 | 307 | @project.issues_with_subprojects(@with_subprojects) do |
|
308 | 308 | events += Issue.find(:all, |
|
309 | 309 | :include => [:tracker, :status, :assigned_to, :priority, :project], |
|
310 | 310 | :conditions => ["((start_date BETWEEN ? AND ?) OR (due_date BETWEEN ? AND ?)) AND #{Issue.table_name}.tracker_id IN (#{@selected_tracker_ids.join(',')})", @calendar.startdt, @calendar.enddt, @calendar.startdt, @calendar.enddt] |
|
311 | 311 | ) unless @selected_tracker_ids.empty? |
|
312 | 312 | end |
|
313 | 313 | events += @project.versions.find(:all, :conditions => ["effective_date BETWEEN ? AND ?", @calendar.startdt, @calendar.enddt]) |
|
314 | 314 | @calendar.events = events |
|
315 | 315 | |
|
316 | 316 | render :layout => false if request.xhr? |
|
317 | 317 | end |
|
318 | 318 | |
|
319 | 319 | def gantt |
|
320 | 320 | @trackers = @project.rolled_up_trackers |
|
321 | 321 | retrieve_selected_tracker_ids(@trackers) |
|
322 | 322 | |
|
323 | 323 | if params[:year] and params[:year].to_i >0 |
|
324 | 324 | @year_from = params[:year].to_i |
|
325 | 325 | if params[:month] and params[:month].to_i >=1 and params[:month].to_i <= 12 |
|
326 | 326 | @month_from = params[:month].to_i |
|
327 | 327 | else |
|
328 | 328 | @month_from = 1 |
|
329 | 329 | end |
|
330 | 330 | else |
|
331 | 331 | @month_from ||= Date.today.month |
|
332 | 332 | @year_from ||= Date.today.year |
|
333 | 333 | end |
|
334 | 334 | |
|
335 | 335 | zoom = (params[:zoom] || User.current.pref[:gantt_zoom]).to_i |
|
336 | 336 | @zoom = (zoom > 0 && zoom < 5) ? zoom : 2 |
|
337 | 337 | months = (params[:months] || User.current.pref[:gantt_months]).to_i |
|
338 | 338 | @months = (months > 0 && months < 25) ? months : 6 |
|
339 | 339 | |
|
340 | 340 | # Save gantt paramters as user preference (zoom and months count) |
|
341 | 341 | if (User.current.logged? && (@zoom != User.current.pref[:gantt_zoom] || @months != User.current.pref[:gantt_months])) |
|
342 | 342 | User.current.pref[:gantt_zoom], User.current.pref[:gantt_months] = @zoom, @months |
|
343 | 343 | User.current.preference.save |
|
344 | 344 | end |
|
345 | 345 | |
|
346 | 346 | @date_from = Date.civil(@year_from, @month_from, 1) |
|
347 | 347 | @date_to = (@date_from >> @months) - 1 |
|
348 | 348 | @with_subprojects = params[:with_subprojects].nil? ? Setting.display_subprojects_issues? : (params[:with_subprojects] == '1') |
|
349 | 349 | |
|
350 | 350 | @events = [] |
|
351 | 351 | @project.issues_with_subprojects(@with_subprojects) do |
|
352 | 352 | @events += Issue.find(:all, |
|
353 | 353 | :order => "start_date, due_date", |
|
354 | 354 | :include => [:tracker, :status, :assigned_to, :priority, :project], |
|
355 | 355 | :conditions => ["(((start_date>=? and start_date<=?) or (due_date>=? and due_date<=?) or (start_date<? and due_date>?)) and start_date is not null and due_date is not null and #{Issue.table_name}.tracker_id in (#{@selected_tracker_ids.join(',')}))", @date_from, @date_to, @date_from, @date_to, @date_from, @date_to] |
|
356 | 356 | ) unless @selected_tracker_ids.empty? |
|
357 | 357 | end |
|
358 | 358 | @events += @project.versions.find(:all, :conditions => ["effective_date BETWEEN ? AND ?", @date_from, @date_to]) |
|
359 | 359 | @events.sort! {|x,y| x.start_date <=> y.start_date } |
|
360 | 360 | |
|
361 | 361 | if params[:format]=='pdf' |
|
362 | 362 | @options_for_rfpdf ||= {} |
|
363 | 363 | @options_for_rfpdf[:file_name] = "#{@project.identifier}-gantt.pdf" |
|
364 | 364 | render :template => "projects/gantt.rfpdf", :layout => false |
|
365 | 365 | elsif params[:format]=='png' && respond_to?('gantt_image') |
|
366 | 366 | image = gantt_image(@events, @date_from, @months, @zoom) |
|
367 | 367 | image.format = 'PNG' |
|
368 | 368 | send_data(image.to_blob, :disposition => 'inline', :type => 'image/png', :filename => "#{@project.identifier}-gantt.png") |
|
369 | 369 | else |
|
370 | 370 | render :template => "projects/gantt.rhtml" |
|
371 | 371 | end |
|
372 | 372 | end |
|
373 | 373 | |
|
374 | 374 | private |
|
375 | 375 | # Find project of id params[:id] |
|
376 | 376 | # if not found, redirect to project list |
|
377 | 377 | # Used as a before_filter |
|
378 | 378 | def find_project |
|
379 | 379 | @project = Project.find(params[:id]) |
|
380 | 380 | rescue ActiveRecord::RecordNotFound |
|
381 | 381 | render_404 |
|
382 | 382 | end |
|
383 | 383 | |
|
384 | 384 | def retrieve_selected_tracker_ids(selectable_trackers) |
|
385 | 385 | if ids = params[:tracker_ids] |
|
386 | 386 | @selected_tracker_ids = (ids.is_a? Array) ? ids.collect { |id| id.to_i.to_s } : ids.split('/').collect { |id| id.to_i.to_s } |
|
387 | 387 | else |
|
388 | 388 | @selected_tracker_ids = selectable_trackers.collect {|t| t.id.to_s } |
|
389 | 389 | end |
|
390 | 390 | end |
|
391 | 391 | end |
General Comments 0
You need to be logged in to leave comments.
Login now