##// END OF EJS Templates
Fixed: upload doesn't work in "Files" section....
Jean-Philippe Lang -
r996:fc26668cd98c
parent child
Show More
@@ -1,548 +1,548
1 # redMine - project management software
1 # redMine - project management software
2 # Copyright (C) 2006-2007 Jean-Philippe Lang
2 # Copyright (C) 2006-2007 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 ProjectsController < ApplicationController
18 class ProjectsController < ApplicationController
19 layout 'base'
19 layout 'base'
20 before_filter :find_project, :except => [ :index, :list, :add ]
20 before_filter :find_project, :except => [ :index, :list, :add ]
21 before_filter :authorize, :except => [ :index, :list, :add, :archive, :unarchive, :destroy ]
21 before_filter :authorize, :except => [ :index, :list, :add, :archive, :unarchive, :destroy ]
22 before_filter :require_admin, :only => [ :add, :archive, :unarchive, :destroy ]
22 before_filter :require_admin, :only => [ :add, :archive, :unarchive, :destroy ]
23 accept_key_auth :activity, :calendar
23 accept_key_auth :activity, :calendar
24
24
25 cache_sweeper :project_sweeper, :only => [ :add, :edit, :archive, :unarchive, :destroy ]
25 cache_sweeper :project_sweeper, :only => [ :add, :edit, :archive, :unarchive, :destroy ]
26 cache_sweeper :issue_sweeper, :only => [ :add_issue ]
26 cache_sweeper :issue_sweeper, :only => [ :add_issue ]
27 cache_sweeper :version_sweeper, :only => [ :add_version ]
27 cache_sweeper :version_sweeper, :only => [ :add_version ]
28
28
29 helper :sort
29 helper :sort
30 include SortHelper
30 include SortHelper
31 helper :custom_fields
31 helper :custom_fields
32 include CustomFieldsHelper
32 include CustomFieldsHelper
33 helper :ifpdf
33 helper :ifpdf
34 include IfpdfHelper
34 include IfpdfHelper
35 helper :issues
35 helper :issues
36 helper IssuesHelper
36 helper IssuesHelper
37 helper :queries
37 helper :queries
38 include QueriesHelper
38 include QueriesHelper
39 helper :repositories
39 helper :repositories
40 include RepositoriesHelper
40 include RepositoriesHelper
41 include ProjectsHelper
41 include ProjectsHelper
42
42
43 def index
43 def index
44 list
44 list
45 render :action => 'list' unless request.xhr?
45 render :action => 'list' unless request.xhr?
46 end
46 end
47
47
48 # Lists visible projects
48 # Lists visible projects
49 def list
49 def list
50 projects = Project.find :all,
50 projects = Project.find :all,
51 :conditions => Project.visible_by(User.current),
51 :conditions => Project.visible_by(User.current),
52 :include => :parent
52 :include => :parent
53 @project_tree = projects.group_by {|p| p.parent || p}
53 @project_tree = projects.group_by {|p| p.parent || p}
54 @project_tree.each_key {|p| @project_tree[p] -= [p]}
54 @project_tree.each_key {|p| @project_tree[p] -= [p]}
55 end
55 end
56
56
57 # Add a new project
57 # Add a new project
58 def add
58 def add
59 @custom_fields = IssueCustomField.find(:all, :order => "#{CustomField.table_name}.position")
59 @custom_fields = IssueCustomField.find(:all, :order => "#{CustomField.table_name}.position")
60 @trackers = Tracker.all
60 @trackers = Tracker.all
61 @root_projects = Project.find(:all,
61 @root_projects = Project.find(:all,
62 :conditions => "parent_id IS NULL AND status = #{Project::STATUS_ACTIVE}",
62 :conditions => "parent_id IS NULL AND status = #{Project::STATUS_ACTIVE}",
63 :order => 'name')
63 :order => 'name')
64 @project = Project.new(params[:project])
64 @project = Project.new(params[:project])
65 @project.enabled_module_names = Redmine::AccessControl.available_project_modules
65 @project.enabled_module_names = Redmine::AccessControl.available_project_modules
66 if request.get?
66 if request.get?
67 @custom_values = ProjectCustomField.find(:all, :order => "#{CustomField.table_name}.position").collect { |x| CustomValue.new(:custom_field => x, :customized => @project) }
67 @custom_values = ProjectCustomField.find(:all, :order => "#{CustomField.table_name}.position").collect { |x| CustomValue.new(:custom_field => x, :customized => @project) }
68 @project.trackers = Tracker.all
68 @project.trackers = Tracker.all
69 else
69 else
70 @project.custom_fields = CustomField.find(params[:custom_field_ids]) if params[:custom_field_ids]
70 @project.custom_fields = CustomField.find(params[:custom_field_ids]) if params[:custom_field_ids]
71 @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)) }
71 @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)) }
72 @project.custom_values = @custom_values
72 @project.custom_values = @custom_values
73 if @project.save
73 if @project.save
74 @project.enabled_module_names = params[:enabled_modules]
74 @project.enabled_module_names = params[:enabled_modules]
75 flash[:notice] = l(:notice_successful_create)
75 flash[:notice] = l(:notice_successful_create)
76 redirect_to :controller => 'admin', :action => 'projects'
76 redirect_to :controller => 'admin', :action => 'projects'
77 end
77 end
78 end
78 end
79 end
79 end
80
80
81 # Show @project
81 # Show @project
82 def show
82 def show
83 @custom_values = @project.custom_values.find(:all, :include => :custom_field, :order => "#{CustomField.table_name}.position")
83 @custom_values = @project.custom_values.find(:all, :include => :custom_field, :order => "#{CustomField.table_name}.position")
84 @members_by_role = @project.members.find(:all, :include => [:user, :role], :order => 'position').group_by {|m| m.role}
84 @members_by_role = @project.members.find(:all, :include => [:user, :role], :order => 'position').group_by {|m| m.role}
85 @subprojects = @project.active_children
85 @subprojects = @project.active_children
86 @news = @project.news.find(:all, :limit => 5, :include => [ :author, :project ], :order => "#{News.table_name}.created_on DESC")
86 @news = @project.news.find(:all, :limit => 5, :include => [ :author, :project ], :order => "#{News.table_name}.created_on DESC")
87 @trackers = @project.trackers
87 @trackers = @project.trackers
88 @open_issues_by_tracker = Issue.count(:group => :tracker, :joins => "INNER JOIN #{IssueStatus.table_name} ON #{IssueStatus.table_name}.id = #{Issue.table_name}.status_id", :conditions => ["project_id=? and #{IssueStatus.table_name}.is_closed=?", @project.id, false])
88 @open_issues_by_tracker = Issue.count(:group => :tracker, :joins => "INNER JOIN #{IssueStatus.table_name} ON #{IssueStatus.table_name}.id = #{Issue.table_name}.status_id", :conditions => ["project_id=? and #{IssueStatus.table_name}.is_closed=?", @project.id, false])
89 @total_issues_by_tracker = Issue.count(:group => :tracker, :conditions => ["project_id=?", @project.id])
89 @total_issues_by_tracker = Issue.count(:group => :tracker, :conditions => ["project_id=?", @project.id])
90 @total_hours = @project.time_entries.sum(:hours)
90 @total_hours = @project.time_entries.sum(:hours)
91 @key = User.current.rss_key
91 @key = User.current.rss_key
92 end
92 end
93
93
94 def settings
94 def settings
95 @root_projects = Project.find(:all,
95 @root_projects = Project.find(:all,
96 :conditions => ["parent_id IS NULL AND status = #{Project::STATUS_ACTIVE} AND id <> ?", @project.id],
96 :conditions => ["parent_id IS NULL AND status = #{Project::STATUS_ACTIVE} AND id <> ?", @project.id],
97 :order => 'name')
97 :order => 'name')
98 @custom_fields = IssueCustomField.find(:all)
98 @custom_fields = IssueCustomField.find(:all)
99 @issue_category ||= IssueCategory.new
99 @issue_category ||= IssueCategory.new
100 @member ||= @project.members.new
100 @member ||= @project.members.new
101 @trackers = Tracker.all
101 @trackers = Tracker.all
102 @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) }
102 @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) }
103 @repository ||= @project.repository
103 @repository ||= @project.repository
104 @wiki ||= @project.wiki
104 @wiki ||= @project.wiki
105 end
105 end
106
106
107 # Edit @project
107 # Edit @project
108 def edit
108 def edit
109 if request.post?
109 if request.post?
110 @project.custom_fields = IssueCustomField.find(params[:custom_field_ids]) if params[:custom_field_ids]
110 @project.custom_fields = IssueCustomField.find(params[:custom_field_ids]) if params[:custom_field_ids]
111 if params[:custom_fields]
111 if params[:custom_fields]
112 @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]) }
112 @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]) }
113 @project.custom_values = @custom_values
113 @project.custom_values = @custom_values
114 end
114 end
115 @project.attributes = params[:project]
115 @project.attributes = params[:project]
116 if @project.save
116 if @project.save
117 flash[:notice] = l(:notice_successful_update)
117 flash[:notice] = l(:notice_successful_update)
118 redirect_to :action => 'settings', :id => @project
118 redirect_to :action => 'settings', :id => @project
119 else
119 else
120 settings
120 settings
121 render :action => 'settings'
121 render :action => 'settings'
122 end
122 end
123 end
123 end
124 end
124 end
125
125
126 def modules
126 def modules
127 @project.enabled_module_names = params[:enabled_modules]
127 @project.enabled_module_names = params[:enabled_modules]
128 redirect_to :action => 'settings', :id => @project, :tab => 'modules'
128 redirect_to :action => 'settings', :id => @project, :tab => 'modules'
129 end
129 end
130
130
131 def archive
131 def archive
132 @project.archive if request.post? && @project.active?
132 @project.archive if request.post? && @project.active?
133 redirect_to :controller => 'admin', :action => 'projects'
133 redirect_to :controller => 'admin', :action => 'projects'
134 end
134 end
135
135
136 def unarchive
136 def unarchive
137 @project.unarchive if request.post? && !@project.active?
137 @project.unarchive if request.post? && !@project.active?
138 redirect_to :controller => 'admin', :action => 'projects'
138 redirect_to :controller => 'admin', :action => 'projects'
139 end
139 end
140
140
141 # Delete @project
141 # Delete @project
142 def destroy
142 def destroy
143 @project_to_destroy = @project
143 @project_to_destroy = @project
144 if request.post? and params[:confirm]
144 if request.post? and params[:confirm]
145 @project_to_destroy.destroy
145 @project_to_destroy.destroy
146 redirect_to :controller => 'admin', :action => 'projects'
146 redirect_to :controller => 'admin', :action => 'projects'
147 end
147 end
148 # hide project in layout
148 # hide project in layout
149 @project = nil
149 @project = nil
150 end
150 end
151
151
152 # Add a new issue category to @project
152 # Add a new issue category to @project
153 def add_issue_category
153 def add_issue_category
154 @category = @project.issue_categories.build(params[:category])
154 @category = @project.issue_categories.build(params[:category])
155 if request.post? and @category.save
155 if request.post? and @category.save
156 respond_to do |format|
156 respond_to do |format|
157 format.html do
157 format.html do
158 flash[:notice] = l(:notice_successful_create)
158 flash[:notice] = l(:notice_successful_create)
159 redirect_to :action => 'settings', :tab => 'categories', :id => @project
159 redirect_to :action => 'settings', :tab => 'categories', :id => @project
160 end
160 end
161 format.js do
161 format.js do
162 # IE doesn't support the replace_html rjs method for select box options
162 # IE doesn't support the replace_html rjs method for select box options
163 render(:update) {|page| page.replace "issue_category_id",
163 render(:update) {|page| page.replace "issue_category_id",
164 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]')
164 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]')
165 }
165 }
166 end
166 end
167 end
167 end
168 end
168 end
169 end
169 end
170
170
171 # Add a new version to @project
171 # Add a new version to @project
172 def add_version
172 def add_version
173 @version = @project.versions.build(params[:version])
173 @version = @project.versions.build(params[:version])
174 if request.post? and @version.save
174 if request.post? and @version.save
175 flash[:notice] = l(:notice_successful_create)
175 flash[:notice] = l(:notice_successful_create)
176 redirect_to :action => 'settings', :tab => 'versions', :id => @project
176 redirect_to :action => 'settings', :tab => 'versions', :id => @project
177 end
177 end
178 end
178 end
179
179
180 # Add a new document to @project
180 # Add a new document to @project
181 def add_document
181 def add_document
182 @document = @project.documents.build(params[:document])
182 @document = @project.documents.build(params[:document])
183 if request.post? and @document.save
183 if request.post? and @document.save
184 attach_files(@document, params[:attachments])
184 attach_files(@document, params[:attachments])
185 flash[:notice] = l(:notice_successful_create)
185 flash[:notice] = l(:notice_successful_create)
186 Mailer.deliver_document_added(@document) if Setting.notified_events.include?('document_added')
186 Mailer.deliver_document_added(@document) if Setting.notified_events.include?('document_added')
187 redirect_to :action => 'list_documents', :id => @project
187 redirect_to :action => 'list_documents', :id => @project
188 end
188 end
189 end
189 end
190
190
191 # Show documents list of @project
191 # Show documents list of @project
192 def list_documents
192 def list_documents
193 @sort_by = %w(category date title author).include?(params[:sort_by]) ? params[:sort_by] : 'category'
193 @sort_by = %w(category date title author).include?(params[:sort_by]) ? params[:sort_by] : 'category'
194 documents = @project.documents.find :all, :include => [:attachments, :category]
194 documents = @project.documents.find :all, :include => [:attachments, :category]
195 case @sort_by
195 case @sort_by
196 when 'date'
196 when 'date'
197 @grouped = documents.group_by {|d| d.created_on.to_date }
197 @grouped = documents.group_by {|d| d.created_on.to_date }
198 when 'title'
198 when 'title'
199 @grouped = documents.group_by {|d| d.title.first.upcase}
199 @grouped = documents.group_by {|d| d.title.first.upcase}
200 when 'author'
200 when 'author'
201 @grouped = documents.select{|d| d.attachments.any?}.group_by {|d| d.attachments.last.author}
201 @grouped = documents.select{|d| d.attachments.any?}.group_by {|d| d.attachments.last.author}
202 else
202 else
203 @grouped = documents.group_by(&:category)
203 @grouped = documents.group_by(&:category)
204 end
204 end
205 render :layout => false if request.xhr?
205 render :layout => false if request.xhr?
206 end
206 end
207
207
208 # Add a new issue to @project
208 # Add a new issue to @project
209 # The new issue will be created from an existing one if copy_from parameter is given
209 # The new issue will be created from an existing one if copy_from parameter is given
210 def add_issue
210 def add_issue
211 @issue = params[:copy_from] ? Issue.new.copy_from(params[:copy_from]) : Issue.new(params[:issue])
211 @issue = params[:copy_from] ? Issue.new.copy_from(params[:copy_from]) : Issue.new(params[:issue])
212 @issue.project = @project
212 @issue.project = @project
213 @issue.author = User.current
213 @issue.author = User.current
214 @issue.tracker ||= @project.trackers.find(params[:tracker_id])
214 @issue.tracker ||= @project.trackers.find(params[:tracker_id])
215
215
216 default_status = IssueStatus.default
216 default_status = IssueStatus.default
217 unless default_status
217 unless default_status
218 flash.now[:error] = 'No default issue status is defined. Please check your configuration (Go to "Administration -> Issue statuses").'
218 flash.now[:error] = 'No default issue status is defined. Please check your configuration (Go to "Administration -> Issue statuses").'
219 render :nothing => true, :layout => true
219 render :nothing => true, :layout => true
220 return
220 return
221 end
221 end
222 @issue.status = default_status
222 @issue.status = default_status
223 @allowed_statuses = ([default_status] + default_status.find_new_statuses_allowed_to(User.current.role_for_project(@project), @issue.tracker))
223 @allowed_statuses = ([default_status] + default_status.find_new_statuses_allowed_to(User.current.role_for_project(@project), @issue.tracker))
224
224
225 if request.get?
225 if request.get?
226 @issue.start_date ||= Date.today
226 @issue.start_date ||= Date.today
227 @custom_values = @issue.custom_values.empty? ?
227 @custom_values = @issue.custom_values.empty? ?
228 @project.custom_fields_for_issues(@issue.tracker).collect { |x| CustomValue.new(:custom_field => x, :customized => @issue) } :
228 @project.custom_fields_for_issues(@issue.tracker).collect { |x| CustomValue.new(:custom_field => x, :customized => @issue) } :
229 @issue.custom_values
229 @issue.custom_values
230 else
230 else
231 requested_status = IssueStatus.find_by_id(params[:issue][:status_id])
231 requested_status = IssueStatus.find_by_id(params[:issue][:status_id])
232 # Check that the user is allowed to apply the requested status
232 # Check that the user is allowed to apply the requested status
233 @issue.status = (@allowed_statuses.include? requested_status) ? requested_status : default_status
233 @issue.status = (@allowed_statuses.include? requested_status) ? requested_status : default_status
234 @custom_values = @project.custom_fields_for_issues(@issue.tracker).collect { |x| CustomValue.new(:custom_field => x, :customized => @issue, :value => params["custom_fields"][x.id.to_s]) }
234 @custom_values = @project.custom_fields_for_issues(@issue.tracker).collect { |x| CustomValue.new(:custom_field => x, :customized => @issue, :value => params["custom_fields"][x.id.to_s]) }
235 @issue.custom_values = @custom_values
235 @issue.custom_values = @custom_values
236 if @issue.save
236 if @issue.save
237 attach_files(@issue, params[:attachments])
237 attach_files(@issue, params[:attachments])
238 flash[:notice] = l(:notice_successful_create)
238 flash[:notice] = l(:notice_successful_create)
239 Mailer.deliver_issue_add(@issue) if Setting.notified_events.include?('issue_added')
239 Mailer.deliver_issue_add(@issue) if Setting.notified_events.include?('issue_added')
240 redirect_to :controller => 'issues', :action => 'index', :project_id => @project
240 redirect_to :controller => 'issues', :action => 'index', :project_id => @project
241 return
241 return
242 end
242 end
243 end
243 end
244 @priorities = Enumeration::get_values('IPRI')
244 @priorities = Enumeration::get_values('IPRI')
245 end
245 end
246
246
247 # Bulk edit issues
247 # Bulk edit issues
248 def bulk_edit_issues
248 def bulk_edit_issues
249 if request.post?
249 if request.post?
250 status = params[:status_id].blank? ? nil : IssueStatus.find_by_id(params[:status_id])
250 status = params[:status_id].blank? ? nil : IssueStatus.find_by_id(params[:status_id])
251 priority = params[:priority_id].blank? ? nil : Enumeration.find_by_id(params[:priority_id])
251 priority = params[:priority_id].blank? ? nil : Enumeration.find_by_id(params[:priority_id])
252 assigned_to = params[:assigned_to_id].blank? ? nil : User.find_by_id(params[:assigned_to_id])
252 assigned_to = params[:assigned_to_id].blank? ? nil : User.find_by_id(params[:assigned_to_id])
253 category = params[:category_id].blank? ? nil : @project.issue_categories.find_by_id(params[:category_id])
253 category = params[:category_id].blank? ? nil : @project.issue_categories.find_by_id(params[:category_id])
254 fixed_version = params[:fixed_version_id].blank? ? nil : @project.versions.find_by_id(params[:fixed_version_id])
254 fixed_version = params[:fixed_version_id].blank? ? nil : @project.versions.find_by_id(params[:fixed_version_id])
255 issues = @project.issues.find_all_by_id(params[:issue_ids])
255 issues = @project.issues.find_all_by_id(params[:issue_ids])
256 unsaved_issue_ids = []
256 unsaved_issue_ids = []
257 issues.each do |issue|
257 issues.each do |issue|
258 journal = issue.init_journal(User.current, params[:notes])
258 journal = issue.init_journal(User.current, params[:notes])
259 issue.priority = priority if priority
259 issue.priority = priority if priority
260 issue.assigned_to = assigned_to if assigned_to || params[:assigned_to_id] == 'none'
260 issue.assigned_to = assigned_to if assigned_to || params[:assigned_to_id] == 'none'
261 issue.category = category if category
261 issue.category = category if category
262 issue.fixed_version = fixed_version if fixed_version
262 issue.fixed_version = fixed_version if fixed_version
263 issue.start_date = params[:start_date] unless params[:start_date].blank?
263 issue.start_date = params[:start_date] unless params[:start_date].blank?
264 issue.due_date = params[:due_date] unless params[:due_date].blank?
264 issue.due_date = params[:due_date] unless params[:due_date].blank?
265 issue.done_ratio = params[:done_ratio] unless params[:done_ratio].blank?
265 issue.done_ratio = params[:done_ratio] unless params[:done_ratio].blank?
266 # Don't save any change to the issue if the user is not authorized to apply the requested status
266 # Don't save any change to the issue if the user is not authorized to apply the requested status
267 if (status.nil? || (issue.status.new_status_allowed_to?(status, current_role, issue.tracker) && issue.status = status)) && issue.save
267 if (status.nil? || (issue.status.new_status_allowed_to?(status, current_role, issue.tracker) && issue.status = status)) && issue.save
268 # Send notification for each issue (if changed)
268 # Send notification for each issue (if changed)
269 Mailer.deliver_issue_edit(journal) if journal.details.any? && Setting.notified_events.include?('issue_updated')
269 Mailer.deliver_issue_edit(journal) if journal.details.any? && Setting.notified_events.include?('issue_updated')
270 else
270 else
271 # Keep unsaved issue ids to display them in flash error
271 # Keep unsaved issue ids to display them in flash error
272 unsaved_issue_ids << issue.id
272 unsaved_issue_ids << issue.id
273 end
273 end
274 end
274 end
275 if unsaved_issue_ids.empty?
275 if unsaved_issue_ids.empty?
276 flash[:notice] = l(:notice_successful_update) unless issues.empty?
276 flash[:notice] = l(:notice_successful_update) unless issues.empty?
277 else
277 else
278 flash[:error] = l(:notice_failed_to_save_issues, unsaved_issue_ids.size, issues.size, '#' + unsaved_issue_ids.join(', #'))
278 flash[:error] = l(:notice_failed_to_save_issues, unsaved_issue_ids.size, issues.size, '#' + unsaved_issue_ids.join(', #'))
279 end
279 end
280 redirect_to :controller => 'issues', :action => 'index', :project_id => @project
280 redirect_to :controller => 'issues', :action => 'index', :project_id => @project
281 return
281 return
282 end
282 end
283 if current_role && User.current.allowed_to?(:change_issue_status, @project)
283 if current_role && User.current.allowed_to?(:change_issue_status, @project)
284 # Find potential statuses the user could be allowed to switch issues to
284 # Find potential statuses the user could be allowed to switch issues to
285 @available_statuses = Workflow.find(:all, :include => :new_status,
285 @available_statuses = Workflow.find(:all, :include => :new_status,
286 :conditions => {:role_id => current_role.id}).collect(&:new_status).compact.uniq
286 :conditions => {:role_id => current_role.id}).collect(&:new_status).compact.uniq
287 end
287 end
288 render :update do |page|
288 render :update do |page|
289 page.hide 'query_form'
289 page.hide 'query_form'
290 page.replace_html 'bulk-edit', :partial => 'issues/bulk_edit_form'
290 page.replace_html 'bulk-edit', :partial => 'issues/bulk_edit_form'
291 end
291 end
292 end
292 end
293
293
294 def move_issues
294 def move_issues
295 @issues = @project.issues.find(params[:issue_ids]) if params[:issue_ids]
295 @issues = @project.issues.find(params[:issue_ids]) if params[:issue_ids]
296 redirect_to :controller => 'issues', :action => 'index', :project_id => @project and return unless @issues
296 redirect_to :controller => 'issues', :action => 'index', :project_id => @project and return unless @issues
297
297
298 @projects = []
298 @projects = []
299 # find projects to which the user is allowed to move the issue
299 # find projects to which the user is allowed to move the issue
300 if User.current.admin?
300 if User.current.admin?
301 # admin is allowed to move issues to any active (visible) project
301 # admin is allowed to move issues to any active (visible) project
302 @projects = Project.find(:all, :conditions => Project.visible_by(User.current), :order => 'name')
302 @projects = Project.find(:all, :conditions => Project.visible_by(User.current), :order => 'name')
303 else
303 else
304 User.current.memberships.each {|m| @projects << m.project if m.role.allowed_to?(:move_issues)}
304 User.current.memberships.each {|m| @projects << m.project if m.role.allowed_to?(:move_issues)}
305 end
305 end
306 @target_project = @projects.detect {|p| p.id.to_s == params[:new_project_id]} if params[:new_project_id]
306 @target_project = @projects.detect {|p| p.id.to_s == params[:new_project_id]} if params[:new_project_id]
307 @target_project ||= @project
307 @target_project ||= @project
308 @trackers = @target_project.trackers
308 @trackers = @target_project.trackers
309 if request.post?
309 if request.post?
310 new_tracker = params[:new_tracker_id].blank? ? nil : @target_project.trackers.find_by_id(params[:new_tracker_id])
310 new_tracker = params[:new_tracker_id].blank? ? nil : @target_project.trackers.find_by_id(params[:new_tracker_id])
311 unsaved_issue_ids = []
311 unsaved_issue_ids = []
312 @issues.each do |issue|
312 @issues.each do |issue|
313 unsaved_issue_ids << issue.id unless issue.move_to(@target_project, new_tracker)
313 unsaved_issue_ids << issue.id unless issue.move_to(@target_project, new_tracker)
314 end
314 end
315 if unsaved_issue_ids.empty?
315 if unsaved_issue_ids.empty?
316 flash[:notice] = l(:notice_successful_update) unless @issues.empty?
316 flash[:notice] = l(:notice_successful_update) unless @issues.empty?
317 else
317 else
318 flash[:error] = l(:notice_failed_to_save_issues, unsaved_issue_ids.size, @issues.size, '#' + unsaved_issue_ids.join(', #'))
318 flash[:error] = l(:notice_failed_to_save_issues, unsaved_issue_ids.size, @issues.size, '#' + unsaved_issue_ids.join(', #'))
319 end
319 end
320 redirect_to :controller => 'issues', :action => 'index', :project_id => @project
320 redirect_to :controller => 'issues', :action => 'index', :project_id => @project
321 return
321 return
322 end
322 end
323 render :layout => false if request.xhr?
323 render :layout => false if request.xhr?
324 end
324 end
325
325
326 # Add a news to @project
326 # Add a news to @project
327 def add_news
327 def add_news
328 @news = News.new(:project => @project, :author => User.current)
328 @news = News.new(:project => @project, :author => User.current)
329 if request.post?
329 if request.post?
330 @news.attributes = params[:news]
330 @news.attributes = params[:news]
331 if @news.save
331 if @news.save
332 flash[:notice] = l(:notice_successful_create)
332 flash[:notice] = l(:notice_successful_create)
333 Mailer.deliver_news_added(@news) if Setting.notified_events.include?('news_added')
333 Mailer.deliver_news_added(@news) if Setting.notified_events.include?('news_added')
334 redirect_to :controller => 'news', :action => 'index', :project_id => @project
334 redirect_to :controller => 'news', :action => 'index', :project_id => @project
335 end
335 end
336 end
336 end
337 end
337 end
338
338
339 def add_file
339 def add_file
340 if request.post?
340 if request.post?
341 @version = @project.versions.find_by_id(params[:version_id])
341 @version = @project.versions.find_by_id(params[:version_id])
342 attachments = attach_files(@issue, params[:attachments])
342 attachments = attach_files(@version, params[:attachments])
343 Mailer.deliver_attachments_added(attachments) if !attachments.empty? && Setting.notified_events.include?('file_added')
343 Mailer.deliver_attachments_added(attachments) if !attachments.empty? && Setting.notified_events.include?('file_added')
344 redirect_to :controller => 'projects', :action => 'list_files', :id => @project
344 redirect_to :controller => 'projects', :action => 'list_files', :id => @project
345 end
345 end
346 @versions = @project.versions.sort
346 @versions = @project.versions.sort
347 end
347 end
348
348
349 def list_files
349 def list_files
350 @versions = @project.versions.sort
350 @versions = @project.versions.sort
351 end
351 end
352
352
353 # Show changelog for @project
353 # Show changelog for @project
354 def changelog
354 def changelog
355 @trackers = @project.trackers.find(:all, :conditions => ["is_in_chlog=?", true], :order => 'position')
355 @trackers = @project.trackers.find(:all, :conditions => ["is_in_chlog=?", true], :order => 'position')
356 retrieve_selected_tracker_ids(@trackers)
356 retrieve_selected_tracker_ids(@trackers)
357 @versions = @project.versions.sort
357 @versions = @project.versions.sort
358 end
358 end
359
359
360 def roadmap
360 def roadmap
361 @trackers = @project.trackers.find(:all, :conditions => ["is_in_roadmap=?", true])
361 @trackers = @project.trackers.find(:all, :conditions => ["is_in_roadmap=?", true])
362 retrieve_selected_tracker_ids(@trackers)
362 retrieve_selected_tracker_ids(@trackers)
363 @versions = @project.versions.sort
363 @versions = @project.versions.sort
364 @versions = @versions.select {|v| !v.completed? } unless params[:completed]
364 @versions = @versions.select {|v| !v.completed? } unless params[:completed]
365 end
365 end
366
366
367 def activity
367 def activity
368 if params[:year] and params[:year].to_i > 1900
368 if params[:year] and params[:year].to_i > 1900
369 @year = params[:year].to_i
369 @year = params[:year].to_i
370 if params[:month] and params[:month].to_i > 0 and params[:month].to_i < 13
370 if params[:month] and params[:month].to_i > 0 and params[:month].to_i < 13
371 @month = params[:month].to_i
371 @month = params[:month].to_i
372 end
372 end
373 end
373 end
374 @year ||= Date.today.year
374 @year ||= Date.today.year
375 @month ||= Date.today.month
375 @month ||= Date.today.month
376
376
377 case params[:format]
377 case params[:format]
378 when 'atom'
378 when 'atom'
379 # 30 last days
379 # 30 last days
380 @date_from = Date.today - 30
380 @date_from = Date.today - 30
381 @date_to = Date.today + 1
381 @date_to = Date.today + 1
382 else
382 else
383 # current month
383 # current month
384 @date_from = Date.civil(@year, @month, 1)
384 @date_from = Date.civil(@year, @month, 1)
385 @date_to = @date_from >> 1
385 @date_to = @date_from >> 1
386 end
386 end
387
387
388 @event_types = %w(issues news files documents changesets wiki_pages messages)
388 @event_types = %w(issues news files documents changesets wiki_pages messages)
389 @event_types.delete('wiki_pages') unless @project.wiki
389 @event_types.delete('wiki_pages') unless @project.wiki
390 @event_types.delete('changesets') unless @project.repository
390 @event_types.delete('changesets') unless @project.repository
391 @event_types.delete('messages') unless @project.boards.any?
391 @event_types.delete('messages') unless @project.boards.any?
392 # only show what the user is allowed to view
392 # only show what the user is allowed to view
393 @event_types = @event_types.select {|o| User.current.allowed_to?("view_#{o}".to_sym, @project)}
393 @event_types = @event_types.select {|o| User.current.allowed_to?("view_#{o}".to_sym, @project)}
394
394
395 @scope = @event_types.select {|t| params["show_#{t}"]}
395 @scope = @event_types.select {|t| params["show_#{t}"]}
396 # default events if none is specified in parameters
396 # default events if none is specified in parameters
397 @scope = (@event_types - %w(wiki_pages messages))if @scope.empty?
397 @scope = (@event_types - %w(wiki_pages messages))if @scope.empty?
398
398
399 @events = []
399 @events = []
400
400
401 if @scope.include?('issues')
401 if @scope.include?('issues')
402 @events += @project.issues.find(:all, :include => [:author, :tracker], :conditions => ["#{Issue.table_name}.created_on>=? and #{Issue.table_name}.created_on<=?", @date_from, @date_to] )
402 @events += @project.issues.find(:all, :include => [:author, :tracker], :conditions => ["#{Issue.table_name}.created_on>=? and #{Issue.table_name}.created_on<=?", @date_from, @date_to] )
403 @events += @project.issues_status_changes(@date_from, @date_to)
403 @events += @project.issues_status_changes(@date_from, @date_to)
404 end
404 end
405
405
406 if @scope.include?('news')
406 if @scope.include?('news')
407 @events += @project.news.find(:all, :conditions => ["#{News.table_name}.created_on>=? and #{News.table_name}.created_on<=?", @date_from, @date_to], :include => :author )
407 @events += @project.news.find(:all, :conditions => ["#{News.table_name}.created_on>=? and #{News.table_name}.created_on<=?", @date_from, @date_to], :include => :author )
408 end
408 end
409
409
410 if @scope.include?('files')
410 if @scope.include?('files')
411 @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 )
411 @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 )
412 end
412 end
413
413
414 if @scope.include?('documents')
414 if @scope.include?('documents')
415 @events += @project.documents.find(:all, :conditions => ["#{Document.table_name}.created_on>=? and #{Document.table_name}.created_on<=?", @date_from, @date_to] )
415 @events += @project.documents.find(:all, :conditions => ["#{Document.table_name}.created_on>=? and #{Document.table_name}.created_on<=?", @date_from, @date_to] )
416 @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 )
416 @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 )
417 end
417 end
418
418
419 if @scope.include?('wiki_pages')
419 if @scope.include?('wiki_pages')
420 select = "#{WikiContent.versioned_table_name}.updated_on, #{WikiContent.versioned_table_name}.comments, " +
420 select = "#{WikiContent.versioned_table_name}.updated_on, #{WikiContent.versioned_table_name}.comments, " +
421 "#{WikiContent.versioned_table_name}.#{WikiContent.version_column}, #{WikiPage.table_name}.title, " +
421 "#{WikiContent.versioned_table_name}.#{WikiContent.version_column}, #{WikiPage.table_name}.title, " +
422 "#{WikiContent.versioned_table_name}.page_id, #{WikiContent.versioned_table_name}.author_id, " +
422 "#{WikiContent.versioned_table_name}.page_id, #{WikiContent.versioned_table_name}.author_id, " +
423 "#{WikiContent.versioned_table_name}.id"
423 "#{WikiContent.versioned_table_name}.id"
424 joins = "LEFT JOIN #{WikiPage.table_name} ON #{WikiPage.table_name}.id = #{WikiContent.versioned_table_name}.page_id " +
424 joins = "LEFT JOIN #{WikiPage.table_name} ON #{WikiPage.table_name}.id = #{WikiContent.versioned_table_name}.page_id " +
425 "LEFT JOIN #{Wiki.table_name} ON #{Wiki.table_name}.id = #{WikiPage.table_name}.wiki_id "
425 "LEFT JOIN #{Wiki.table_name} ON #{Wiki.table_name}.id = #{WikiPage.table_name}.wiki_id "
426 conditions = ["#{Wiki.table_name}.project_id = ? AND #{WikiContent.versioned_table_name}.updated_on BETWEEN ? AND ?",
426 conditions = ["#{Wiki.table_name}.project_id = ? AND #{WikiContent.versioned_table_name}.updated_on BETWEEN ? AND ?",
427 @project.id, @date_from, @date_to]
427 @project.id, @date_from, @date_to]
428
428
429 @events += WikiContent.versioned_class.find(:all, :select => select, :joins => joins, :conditions => conditions)
429 @events += WikiContent.versioned_class.find(:all, :select => select, :joins => joins, :conditions => conditions)
430 end
430 end
431
431
432 if @scope.include?('changesets')
432 if @scope.include?('changesets')
433 @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])
433 @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])
434 end
434 end
435
435
436 if @scope.include?('messages')
436 if @scope.include?('messages')
437 @events += Message.find(:all,
437 @events += Message.find(:all,
438 :include => [:board, :author],
438 :include => [:board, :author],
439 :conditions => ["#{Board.table_name}.project_id=? AND #{Message.table_name}.parent_id IS NULL AND #{Message.table_name}.created_on BETWEEN ? AND ?", @project.id, @date_from, @date_to])
439 :conditions => ["#{Board.table_name}.project_id=? AND #{Message.table_name}.parent_id IS NULL AND #{Message.table_name}.created_on BETWEEN ? AND ?", @project.id, @date_from, @date_to])
440 end
440 end
441
441
442 @events_by_day = @events.group_by(&:event_date)
442 @events_by_day = @events.group_by(&:event_date)
443
443
444 respond_to do |format|
444 respond_to do |format|
445 format.html { render :layout => false if request.xhr? }
445 format.html { render :layout => false if request.xhr? }
446 format.atom { render_feed(@events, :title => "#{@project.name}: #{l(:label_activity)}") }
446 format.atom { render_feed(@events, :title => "#{@project.name}: #{l(:label_activity)}") }
447 end
447 end
448 end
448 end
449
449
450 def calendar
450 def calendar
451 @trackers = Tracker.find(:all, :order => 'position')
451 @trackers = Tracker.find(:all, :order => 'position')
452 retrieve_selected_tracker_ids(@trackers)
452 retrieve_selected_tracker_ids(@trackers)
453
453
454 if params[:year] and params[:year].to_i > 1900
454 if params[:year] and params[:year].to_i > 1900
455 @year = params[:year].to_i
455 @year = params[:year].to_i
456 if params[:month] and params[:month].to_i > 0 and params[:month].to_i < 13
456 if params[:month] and params[:month].to_i > 0 and params[:month].to_i < 13
457 @month = params[:month].to_i
457 @month = params[:month].to_i
458 end
458 end
459 end
459 end
460 @year ||= Date.today.year
460 @year ||= Date.today.year
461 @month ||= Date.today.month
461 @month ||= Date.today.month
462 @calendar = Redmine::Helpers::Calendar.new(Date.civil(@year, @month, 1), current_language, :month)
462 @calendar = Redmine::Helpers::Calendar.new(Date.civil(@year, @month, 1), current_language, :month)
463
463
464 events = []
464 events = []
465 @project.issues_with_subprojects(params[:with_subprojects]) do
465 @project.issues_with_subprojects(params[:with_subprojects]) do
466 events += Issue.find(:all,
466 events += Issue.find(:all,
467 :include => [:tracker, :status, :assigned_to, :priority, :project],
467 :include => [:tracker, :status, :assigned_to, :priority, :project],
468 :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]
468 :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]
469 ) unless @selected_tracker_ids.empty?
469 ) unless @selected_tracker_ids.empty?
470 end
470 end
471 events += @project.versions.find(:all, :conditions => ["effective_date BETWEEN ? AND ?", @calendar.startdt, @calendar.enddt])
471 events += @project.versions.find(:all, :conditions => ["effective_date BETWEEN ? AND ?", @calendar.startdt, @calendar.enddt])
472 @calendar.events = events
472 @calendar.events = events
473
473
474 render :layout => false if request.xhr?
474 render :layout => false if request.xhr?
475 end
475 end
476
476
477 def gantt
477 def gantt
478 @trackers = Tracker.find(:all, :order => 'position')
478 @trackers = Tracker.find(:all, :order => 'position')
479 retrieve_selected_tracker_ids(@trackers)
479 retrieve_selected_tracker_ids(@trackers)
480
480
481 if params[:year] and params[:year].to_i >0
481 if params[:year] and params[:year].to_i >0
482 @year_from = params[:year].to_i
482 @year_from = params[:year].to_i
483 if params[:month] and params[:month].to_i >=1 and params[:month].to_i <= 12
483 if params[:month] and params[:month].to_i >=1 and params[:month].to_i <= 12
484 @month_from = params[:month].to_i
484 @month_from = params[:month].to_i
485 else
485 else
486 @month_from = 1
486 @month_from = 1
487 end
487 end
488 else
488 else
489 @month_from ||= Date.today.month
489 @month_from ||= Date.today.month
490 @year_from ||= Date.today.year
490 @year_from ||= Date.today.year
491 end
491 end
492
492
493 zoom = (params[:zoom] || User.current.pref[:gantt_zoom]).to_i
493 zoom = (params[:zoom] || User.current.pref[:gantt_zoom]).to_i
494 @zoom = (zoom > 0 && zoom < 5) ? zoom : 2
494 @zoom = (zoom > 0 && zoom < 5) ? zoom : 2
495 months = (params[:months] || User.current.pref[:gantt_months]).to_i
495 months = (params[:months] || User.current.pref[:gantt_months]).to_i
496 @months = (months > 0 && months < 25) ? months : 6
496 @months = (months > 0 && months < 25) ? months : 6
497
497
498 # Save gantt paramters as user preference (zoom and months count)
498 # Save gantt paramters as user preference (zoom and months count)
499 if (User.current.logged? && (@zoom != User.current.pref[:gantt_zoom] || @months != User.current.pref[:gantt_months]))
499 if (User.current.logged? && (@zoom != User.current.pref[:gantt_zoom] || @months != User.current.pref[:gantt_months]))
500 User.current.pref[:gantt_zoom], User.current.pref[:gantt_months] = @zoom, @months
500 User.current.pref[:gantt_zoom], User.current.pref[:gantt_months] = @zoom, @months
501 User.current.preference.save
501 User.current.preference.save
502 end
502 end
503
503
504 @date_from = Date.civil(@year_from, @month_from, 1)
504 @date_from = Date.civil(@year_from, @month_from, 1)
505 @date_to = (@date_from >> @months) - 1
505 @date_to = (@date_from >> @months) - 1
506
506
507 @events = []
507 @events = []
508 @project.issues_with_subprojects(params[:with_subprojects]) do
508 @project.issues_with_subprojects(params[:with_subprojects]) do
509 @events += Issue.find(:all,
509 @events += Issue.find(:all,
510 :order => "start_date, due_date",
510 :order => "start_date, due_date",
511 :include => [:tracker, :status, :assigned_to, :priority, :project],
511 :include => [:tracker, :status, :assigned_to, :priority, :project],
512 :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]
512 :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]
513 ) unless @selected_tracker_ids.empty?
513 ) unless @selected_tracker_ids.empty?
514 end
514 end
515 @events += @project.versions.find(:all, :conditions => ["effective_date BETWEEN ? AND ?", @date_from, @date_to])
515 @events += @project.versions.find(:all, :conditions => ["effective_date BETWEEN ? AND ?", @date_from, @date_to])
516 @events.sort! {|x,y| x.start_date <=> y.start_date }
516 @events.sort! {|x,y| x.start_date <=> y.start_date }
517
517
518 if params[:format]=='pdf'
518 if params[:format]=='pdf'
519 @options_for_rfpdf ||= {}
519 @options_for_rfpdf ||= {}
520 @options_for_rfpdf[:file_name] = "#{@project.identifier}-gantt.pdf"
520 @options_for_rfpdf[:file_name] = "#{@project.identifier}-gantt.pdf"
521 render :template => "projects/gantt.rfpdf", :layout => false
521 render :template => "projects/gantt.rfpdf", :layout => false
522 elsif params[:format]=='png' && respond_to?('gantt_image')
522 elsif params[:format]=='png' && respond_to?('gantt_image')
523 image = gantt_image(@events, @date_from, @months, @zoom)
523 image = gantt_image(@events, @date_from, @months, @zoom)
524 image.format = 'PNG'
524 image.format = 'PNG'
525 send_data(image.to_blob, :disposition => 'inline', :type => 'image/png', :filename => "#{@project.identifier}-gantt.png")
525 send_data(image.to_blob, :disposition => 'inline', :type => 'image/png', :filename => "#{@project.identifier}-gantt.png")
526 else
526 else
527 render :template => "projects/gantt.rhtml"
527 render :template => "projects/gantt.rhtml"
528 end
528 end
529 end
529 end
530
530
531 private
531 private
532 # Find project of id params[:id]
532 # Find project of id params[:id]
533 # if not found, redirect to project list
533 # if not found, redirect to project list
534 # Used as a before_filter
534 # Used as a before_filter
535 def find_project
535 def find_project
536 @project = Project.find(params[:id])
536 @project = Project.find(params[:id])
537 rescue ActiveRecord::RecordNotFound
537 rescue ActiveRecord::RecordNotFound
538 render_404
538 render_404
539 end
539 end
540
540
541 def retrieve_selected_tracker_ids(selectable_trackers)
541 def retrieve_selected_tracker_ids(selectable_trackers)
542 if ids = params[:tracker_ids]
542 if ids = params[:tracker_ids]
543 @selected_tracker_ids = (ids.is_a? Array) ? ids.collect { |id| id.to_i.to_s } : ids.split('/').collect { |id| id.to_i.to_s }
543 @selected_tracker_ids = (ids.is_a? Array) ? ids.collect { |id| id.to_i.to_s } : ids.split('/').collect { |id| id.to_i.to_s }
544 else
544 else
545 @selected_tracker_ids = selectable_trackers.collect {|t| t.id.to_s }
545 @selected_tracker_ids = selectable_trackers.collect {|t| t.id.to_s }
546 end
546 end
547 end
547 end
548 end
548 end
General Comments 0
You need to be logged in to leave comments. Login now