@@ -1,345 +1,346 | |||||
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 | menu_item :overview |
|
19 | menu_item :overview | |
20 | menu_item :activity, :only => :activity |
|
20 | menu_item :activity, :only => :activity | |
21 | menu_item :roadmap, :only => :roadmap |
|
21 | menu_item :roadmap, :only => :roadmap | |
22 | menu_item :files, :only => [:list_files, :add_file] |
|
22 | menu_item :files, :only => [:list_files, :add_file] | |
23 | menu_item :settings, :only => :settings |
|
23 | menu_item :settings, :only => :settings | |
24 | menu_item :issues, :only => [:changelog] |
|
24 | menu_item :issues, :only => [:changelog] | |
25 |
|
25 | |||
26 | before_filter :find_project, :except => [ :index, :list, :add, :copy, :activity ] |
|
26 | before_filter :find_project, :except => [ :index, :list, :add, :copy, :activity ] | |
27 | before_filter :find_optional_project, :only => :activity |
|
27 | before_filter :find_optional_project, :only => :activity | |
28 | before_filter :authorize, :except => [ :index, :list, :add, :copy, :archive, :unarchive, :destroy, :activity ] |
|
28 | before_filter :authorize, :except => [ :index, :list, :add, :copy, :archive, :unarchive, :destroy, :activity ] | |
29 | before_filter :authorize_global, :only => :add |
|
29 | before_filter :authorize_global, :only => :add | |
30 | before_filter :require_admin, :only => [ :copy, :archive, :unarchive, :destroy ] |
|
30 | before_filter :require_admin, :only => [ :copy, :archive, :unarchive, :destroy ] | |
31 | accept_key_auth :activity |
|
31 | accept_key_auth :activity | |
32 |
|
32 | |||
33 | after_filter :only => [:add, :edit, :archive, :unarchive, :destroy] do |controller| |
|
33 | after_filter :only => [:add, :edit, :archive, :unarchive, :destroy] do |controller| | |
34 | if controller.request.post? |
|
34 | if controller.request.post? | |
35 | controller.send :expire_action, :controller => 'welcome', :action => 'robots.txt' |
|
35 | controller.send :expire_action, :controller => 'welcome', :action => 'robots.txt' | |
36 | end |
|
36 | end | |
37 | end |
|
37 | end | |
38 |
|
38 | |||
39 | helper :sort |
|
39 | helper :sort | |
40 | include SortHelper |
|
40 | include SortHelper | |
41 | helper :custom_fields |
|
41 | helper :custom_fields | |
42 | include CustomFieldsHelper |
|
42 | include CustomFieldsHelper | |
43 | helper :issues |
|
43 | helper :issues | |
44 | helper IssuesHelper |
|
44 | helper IssuesHelper | |
45 | helper :queries |
|
45 | helper :queries | |
46 | include QueriesHelper |
|
46 | include QueriesHelper | |
47 | helper :repositories |
|
47 | helper :repositories | |
48 | include RepositoriesHelper |
|
48 | include RepositoriesHelper | |
49 | include ProjectsHelper |
|
49 | include ProjectsHelper | |
50 |
|
50 | |||
51 | # Lists visible projects |
|
51 | # Lists visible projects | |
52 | def index |
|
52 | def index | |
53 | respond_to do |format| |
|
53 | respond_to do |format| | |
54 | format.html { |
|
54 | format.html { | |
55 | @projects = Project.visible.find(:all, :order => 'lft') |
|
55 | @projects = Project.visible.find(:all, :order => 'lft') | |
56 | } |
|
56 | } | |
57 | format.atom { |
|
57 | format.atom { | |
58 | projects = Project.visible.find(:all, :order => 'created_on DESC', |
|
58 | projects = Project.visible.find(:all, :order => 'created_on DESC', | |
59 | :limit => Setting.feeds_limit.to_i) |
|
59 | :limit => Setting.feeds_limit.to_i) | |
60 | render_feed(projects, :title => "#{Setting.app_title}: #{l(:label_project_latest)}") |
|
60 | render_feed(projects, :title => "#{Setting.app_title}: #{l(:label_project_latest)}") | |
61 | } |
|
61 | } | |
62 | end |
|
62 | end | |
63 | end |
|
63 | end | |
64 |
|
64 | |||
65 | # Add a new project |
|
65 | # Add a new project | |
66 | def add |
|
66 | def add | |
67 | @issue_custom_fields = IssueCustomField.find(:all, :order => "#{CustomField.table_name}.position") |
|
67 | @issue_custom_fields = IssueCustomField.find(:all, :order => "#{CustomField.table_name}.position") | |
68 | @trackers = Tracker.all |
|
68 | @trackers = Tracker.all | |
69 | @project = Project.new(params[:project]) |
|
69 | @project = Project.new(params[:project]) | |
70 | if request.get? |
|
70 | if request.get? | |
71 | @project.identifier = Project.next_identifier if Setting.sequential_project_identifiers? |
|
71 | @project.identifier = Project.next_identifier if Setting.sequential_project_identifiers? | |
72 | @project.trackers = Tracker.all |
|
72 | @project.trackers = Tracker.all | |
73 | @project.is_public = Setting.default_projects_public? |
|
73 | @project.is_public = Setting.default_projects_public? | |
74 | @project.enabled_module_names = Redmine::AccessControl.available_project_modules |
|
74 | @project.enabled_module_names = Redmine::AccessControl.available_project_modules | |
75 | else |
|
75 | else | |
76 | @project.enabled_module_names = params[:enabled_modules] |
|
76 | @project.enabled_module_names = params[:enabled_modules] | |
77 | if @project.save |
|
77 | if @project.save | |
78 | @project.set_parent!(params[:project]['parent_id']) if User.current.admin? && params[:project].has_key?('parent_id') |
|
78 | @project.set_parent!(params[:project]['parent_id']) if User.current.admin? && params[:project].has_key?('parent_id') | |
79 | # Add current user as a project member if he is not admin |
|
79 | # Add current user as a project member if he is not admin | |
80 | unless User.current.admin? |
|
80 | unless User.current.admin? | |
81 | r = Role.givable.find_by_id(Setting.new_project_user_role_id.to_i) || Role.givable.first |
|
81 | r = Role.givable.find_by_id(Setting.new_project_user_role_id.to_i) || Role.givable.first | |
82 | m = Member.new(:user => User.current, :roles => [r]) |
|
82 | m = Member.new(:user => User.current, :roles => [r]) | |
83 | @project.members << m |
|
83 | @project.members << m | |
84 | end |
|
84 | end | |
85 | flash[:notice] = l(:notice_successful_create) |
|
85 | flash[:notice] = l(:notice_successful_create) | |
86 | redirect_to :controller => 'projects', :action => 'settings', :id => @project |
|
86 | redirect_to :controller => 'projects', :action => 'settings', :id => @project | |
87 | end |
|
87 | end | |
88 | end |
|
88 | end | |
89 | end |
|
89 | end | |
90 |
|
90 | |||
91 | def copy |
|
91 | def copy | |
92 | @issue_custom_fields = IssueCustomField.find(:all, :order => "#{CustomField.table_name}.position") |
|
92 | @issue_custom_fields = IssueCustomField.find(:all, :order => "#{CustomField.table_name}.position") | |
93 | @trackers = Tracker.all |
|
93 | @trackers = Tracker.all | |
94 | @root_projects = Project.find(:all, |
|
94 | @root_projects = Project.find(:all, | |
95 | :conditions => "parent_id IS NULL AND status = #{Project::STATUS_ACTIVE}", |
|
95 | :conditions => "parent_id IS NULL AND status = #{Project::STATUS_ACTIVE}", | |
96 | :order => 'name') |
|
96 | :order => 'name') | |
97 | if request.get? |
|
97 | if request.get? | |
98 | @project = Project.copy_from(params[:id]) |
|
98 | @project = Project.copy_from(params[:id]) | |
99 | if @project |
|
99 | if @project | |
100 | @project.identifier = Project.next_identifier if Setting.sequential_project_identifiers? |
|
100 | @project.identifier = Project.next_identifier if Setting.sequential_project_identifiers? | |
101 | else |
|
101 | else | |
102 | redirect_to :controller => 'admin', :action => 'projects' |
|
102 | redirect_to :controller => 'admin', :action => 'projects' | |
103 | end |
|
103 | end | |
104 | else |
|
104 | else | |
105 | @project = Project.new(params[:project]) |
|
105 | @project = Project.new(params[:project]) | |
106 | @project.enabled_module_names = params[:enabled_modules] |
|
106 | @project.enabled_module_names = params[:enabled_modules] | |
107 | if @project.copy(params[:id], :only => params[:only]) |
|
107 | if @project.copy(params[:id], :only => params[:only]) | |
|
108 | @project.set_parent!(params[:project]['parent_id']) if User.current.admin? && params[:project].has_key?('parent_id') | |||
108 | flash[:notice] = l(:notice_successful_create) |
|
109 | flash[:notice] = l(:notice_successful_create) | |
109 | redirect_to :controller => 'admin', :action => 'projects' |
|
110 | redirect_to :controller => 'admin', :action => 'projects' | |
110 | end |
|
111 | end | |
111 | end |
|
112 | end | |
112 | end |
|
113 | end | |
113 |
|
114 | |||
114 |
|
115 | |||
115 | # Show @project |
|
116 | # Show @project | |
116 | def show |
|
117 | def show | |
117 | if params[:jump] |
|
118 | if params[:jump] | |
118 | # try to redirect to the requested menu item |
|
119 | # try to redirect to the requested menu item | |
119 | redirect_to_project_menu_item(@project, params[:jump]) && return |
|
120 | redirect_to_project_menu_item(@project, params[:jump]) && return | |
120 | end |
|
121 | end | |
121 |
|
122 | |||
122 | @users_by_role = @project.users_by_role |
|
123 | @users_by_role = @project.users_by_role | |
123 | @subprojects = @project.children.visible |
|
124 | @subprojects = @project.children.visible | |
124 | @news = @project.news.find(:all, :limit => 5, :include => [ :author, :project ], :order => "#{News.table_name}.created_on DESC") |
|
125 | @news = @project.news.find(:all, :limit => 5, :include => [ :author, :project ], :order => "#{News.table_name}.created_on DESC") | |
125 | @trackers = @project.rolled_up_trackers |
|
126 | @trackers = @project.rolled_up_trackers | |
126 |
|
127 | |||
127 | cond = @project.project_condition(Setting.display_subprojects_issues?) |
|
128 | cond = @project.project_condition(Setting.display_subprojects_issues?) | |
128 |
|
129 | |||
129 | @open_issues_by_tracker = Issue.visible.count(:group => :tracker, |
|
130 | @open_issues_by_tracker = Issue.visible.count(:group => :tracker, | |
130 | :include => [:project, :status, :tracker], |
|
131 | :include => [:project, :status, :tracker], | |
131 | :conditions => ["(#{cond}) AND #{IssueStatus.table_name}.is_closed=?", false]) |
|
132 | :conditions => ["(#{cond}) AND #{IssueStatus.table_name}.is_closed=?", false]) | |
132 | @total_issues_by_tracker = Issue.visible.count(:group => :tracker, |
|
133 | @total_issues_by_tracker = Issue.visible.count(:group => :tracker, | |
133 | :include => [:project, :status, :tracker], |
|
134 | :include => [:project, :status, :tracker], | |
134 | :conditions => cond) |
|
135 | :conditions => cond) | |
135 |
|
136 | |||
136 | TimeEntry.visible_by(User.current) do |
|
137 | TimeEntry.visible_by(User.current) do | |
137 | @total_hours = TimeEntry.sum(:hours, |
|
138 | @total_hours = TimeEntry.sum(:hours, | |
138 | :include => :project, |
|
139 | :include => :project, | |
139 | :conditions => cond).to_f |
|
140 | :conditions => cond).to_f | |
140 | end |
|
141 | end | |
141 | @key = User.current.rss_key |
|
142 | @key = User.current.rss_key | |
142 | end |
|
143 | end | |
143 |
|
144 | |||
144 | def settings |
|
145 | def settings | |
145 | @issue_custom_fields = IssueCustomField.find(:all, :order => "#{CustomField.table_name}.position") |
|
146 | @issue_custom_fields = IssueCustomField.find(:all, :order => "#{CustomField.table_name}.position") | |
146 | @issue_category ||= IssueCategory.new |
|
147 | @issue_category ||= IssueCategory.new | |
147 | @member ||= @project.members.new |
|
148 | @member ||= @project.members.new | |
148 | @trackers = Tracker.all |
|
149 | @trackers = Tracker.all | |
149 | @repository ||= @project.repository |
|
150 | @repository ||= @project.repository | |
150 | @wiki ||= @project.wiki |
|
151 | @wiki ||= @project.wiki | |
151 | end |
|
152 | end | |
152 |
|
153 | |||
153 | # Edit @project |
|
154 | # Edit @project | |
154 | def edit |
|
155 | def edit | |
155 | if request.post? |
|
156 | if request.post? | |
156 | @project.attributes = params[:project] |
|
157 | @project.attributes = params[:project] | |
157 | if @project.save |
|
158 | if @project.save | |
158 | @project.set_parent!(params[:project]['parent_id']) if User.current.admin? && params[:project].has_key?('parent_id') |
|
159 | @project.set_parent!(params[:project]['parent_id']) if User.current.admin? && params[:project].has_key?('parent_id') | |
159 | flash[:notice] = l(:notice_successful_update) |
|
160 | flash[:notice] = l(:notice_successful_update) | |
160 | redirect_to :action => 'settings', :id => @project |
|
161 | redirect_to :action => 'settings', :id => @project | |
161 | else |
|
162 | else | |
162 | settings |
|
163 | settings | |
163 | render :action => 'settings' |
|
164 | render :action => 'settings' | |
164 | end |
|
165 | end | |
165 | end |
|
166 | end | |
166 | end |
|
167 | end | |
167 |
|
168 | |||
168 | def modules |
|
169 | def modules | |
169 | @project.enabled_module_names = params[:enabled_modules] |
|
170 | @project.enabled_module_names = params[:enabled_modules] | |
170 | redirect_to :action => 'settings', :id => @project, :tab => 'modules' |
|
171 | redirect_to :action => 'settings', :id => @project, :tab => 'modules' | |
171 | end |
|
172 | end | |
172 |
|
173 | |||
173 | def archive |
|
174 | def archive | |
174 | @project.archive if request.post? && @project.active? |
|
175 | @project.archive if request.post? && @project.active? | |
175 | redirect_to(url_for(:controller => 'admin', :action => 'projects', :status => params[:status])) |
|
176 | redirect_to(url_for(:controller => 'admin', :action => 'projects', :status => params[:status])) | |
176 | end |
|
177 | end | |
177 |
|
178 | |||
178 | def unarchive |
|
179 | def unarchive | |
179 | @project.unarchive if request.post? && !@project.active? |
|
180 | @project.unarchive if request.post? && !@project.active? | |
180 | redirect_to(url_for(:controller => 'admin', :action => 'projects', :status => params[:status])) |
|
181 | redirect_to(url_for(:controller => 'admin', :action => 'projects', :status => params[:status])) | |
181 | end |
|
182 | end | |
182 |
|
183 | |||
183 | # Delete @project |
|
184 | # Delete @project | |
184 | def destroy |
|
185 | def destroy | |
185 | @project_to_destroy = @project |
|
186 | @project_to_destroy = @project | |
186 | if request.post? and params[:confirm] |
|
187 | if request.post? and params[:confirm] | |
187 | @project_to_destroy.destroy |
|
188 | @project_to_destroy.destroy | |
188 | redirect_to :controller => 'admin', :action => 'projects' |
|
189 | redirect_to :controller => 'admin', :action => 'projects' | |
189 | end |
|
190 | end | |
190 | # hide project in layout |
|
191 | # hide project in layout | |
191 | @project = nil |
|
192 | @project = nil | |
192 | end |
|
193 | end | |
193 |
|
194 | |||
194 | # Add a new issue category to @project |
|
195 | # Add a new issue category to @project | |
195 | def add_issue_category |
|
196 | def add_issue_category | |
196 | @category = @project.issue_categories.build(params[:category]) |
|
197 | @category = @project.issue_categories.build(params[:category]) | |
197 | if request.post? and @category.save |
|
198 | if request.post? and @category.save | |
198 | respond_to do |format| |
|
199 | respond_to do |format| | |
199 | format.html do |
|
200 | format.html do | |
200 | flash[:notice] = l(:notice_successful_create) |
|
201 | flash[:notice] = l(:notice_successful_create) | |
201 | redirect_to :action => 'settings', :tab => 'categories', :id => @project |
|
202 | redirect_to :action => 'settings', :tab => 'categories', :id => @project | |
202 | end |
|
203 | end | |
203 | format.js do |
|
204 | format.js do | |
204 | # IE doesn't support the replace_html rjs method for select box options |
|
205 | # IE doesn't support the replace_html rjs method for select box options | |
205 | render(:update) {|page| page.replace "issue_category_id", |
|
206 | render(:update) {|page| page.replace "issue_category_id", | |
206 | 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]') |
|
207 | 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]') | |
207 | } |
|
208 | } | |
208 | end |
|
209 | end | |
209 | end |
|
210 | end | |
210 | end |
|
211 | end | |
211 | end |
|
212 | end | |
212 |
|
213 | |||
213 | # Add a new version to @project |
|
214 | # Add a new version to @project | |
214 | def add_version |
|
215 | def add_version | |
215 | @version = @project.versions.build(params[:version]) |
|
216 | @version = @project.versions.build(params[:version]) | |
216 | if request.post? and @version.save |
|
217 | if request.post? and @version.save | |
217 | flash[:notice] = l(:notice_successful_create) |
|
218 | flash[:notice] = l(:notice_successful_create) | |
218 | redirect_to :action => 'settings', :tab => 'versions', :id => @project |
|
219 | redirect_to :action => 'settings', :tab => 'versions', :id => @project | |
219 | end |
|
220 | end | |
220 | end |
|
221 | end | |
221 |
|
222 | |||
222 | def add_file |
|
223 | def add_file | |
223 | if request.post? |
|
224 | if request.post? | |
224 | container = (params[:version_id].blank? ? @project : @project.versions.find_by_id(params[:version_id])) |
|
225 | container = (params[:version_id].blank? ? @project : @project.versions.find_by_id(params[:version_id])) | |
225 | attachments = attach_files(container, params[:attachments]) |
|
226 | attachments = attach_files(container, params[:attachments]) | |
226 | if !attachments.empty? && Setting.notified_events.include?('file_added') |
|
227 | if !attachments.empty? && Setting.notified_events.include?('file_added') | |
227 | Mailer.deliver_attachments_added(attachments) |
|
228 | Mailer.deliver_attachments_added(attachments) | |
228 | end |
|
229 | end | |
229 | redirect_to :controller => 'projects', :action => 'list_files', :id => @project |
|
230 | redirect_to :controller => 'projects', :action => 'list_files', :id => @project | |
230 | return |
|
231 | return | |
231 | end |
|
232 | end | |
232 | @versions = @project.versions.sort |
|
233 | @versions = @project.versions.sort | |
233 | end |
|
234 | end | |
234 |
|
235 | |||
235 | def save_activities |
|
236 | def save_activities | |
236 | if request.post? && params[:enumerations] |
|
237 | if request.post? && params[:enumerations] | |
237 | Project.transaction do |
|
238 | Project.transaction do | |
238 | params[:enumerations].each do |id, activity| |
|
239 | params[:enumerations].each do |id, activity| | |
239 | @project.update_or_create_time_entry_activity(id, activity) |
|
240 | @project.update_or_create_time_entry_activity(id, activity) | |
240 | end |
|
241 | end | |
241 | end |
|
242 | end | |
242 | end |
|
243 | end | |
243 |
|
244 | |||
244 | redirect_to :controller => 'projects', :action => 'settings', :tab => 'activities', :id => @project |
|
245 | redirect_to :controller => 'projects', :action => 'settings', :tab => 'activities', :id => @project | |
245 | end |
|
246 | end | |
246 |
|
247 | |||
247 | def reset_activities |
|
248 | def reset_activities | |
248 | @project.time_entry_activities.each do |time_entry_activity| |
|
249 | @project.time_entry_activities.each do |time_entry_activity| | |
249 | time_entry_activity.destroy(time_entry_activity.parent) |
|
250 | time_entry_activity.destroy(time_entry_activity.parent) | |
250 | end |
|
251 | end | |
251 | redirect_to :controller => 'projects', :action => 'settings', :tab => 'activities', :id => @project |
|
252 | redirect_to :controller => 'projects', :action => 'settings', :tab => 'activities', :id => @project | |
252 | end |
|
253 | end | |
253 |
|
254 | |||
254 | def list_files |
|
255 | def list_files | |
255 | sort_init 'filename', 'asc' |
|
256 | sort_init 'filename', 'asc' | |
256 | sort_update 'filename' => "#{Attachment.table_name}.filename", |
|
257 | sort_update 'filename' => "#{Attachment.table_name}.filename", | |
257 | 'created_on' => "#{Attachment.table_name}.created_on", |
|
258 | 'created_on' => "#{Attachment.table_name}.created_on", | |
258 | 'size' => "#{Attachment.table_name}.filesize", |
|
259 | 'size' => "#{Attachment.table_name}.filesize", | |
259 | 'downloads' => "#{Attachment.table_name}.downloads" |
|
260 | 'downloads' => "#{Attachment.table_name}.downloads" | |
260 |
|
261 | |||
261 | @containers = [ Project.find(@project.id, :include => :attachments, :order => sort_clause)] |
|
262 | @containers = [ Project.find(@project.id, :include => :attachments, :order => sort_clause)] | |
262 | @containers += @project.versions.find(:all, :include => :attachments, :order => sort_clause).sort.reverse |
|
263 | @containers += @project.versions.find(:all, :include => :attachments, :order => sort_clause).sort.reverse | |
263 | render :layout => !request.xhr? |
|
264 | render :layout => !request.xhr? | |
264 | end |
|
265 | end | |
265 |
|
266 | |||
266 | # Show changelog for @project |
|
267 | # Show changelog for @project | |
267 | def changelog |
|
268 | def changelog | |
268 | @trackers = @project.trackers.find(:all, :conditions => ["is_in_chlog=?", true], :order => 'position') |
|
269 | @trackers = @project.trackers.find(:all, :conditions => ["is_in_chlog=?", true], :order => 'position') | |
269 | retrieve_selected_tracker_ids(@trackers) |
|
270 | retrieve_selected_tracker_ids(@trackers) | |
270 | @versions = @project.versions.sort |
|
271 | @versions = @project.versions.sort | |
271 | end |
|
272 | end | |
272 |
|
273 | |||
273 | def roadmap |
|
274 | def roadmap | |
274 | @trackers = @project.trackers.find(:all, :conditions => ["is_in_roadmap=?", true]) |
|
275 | @trackers = @project.trackers.find(:all, :conditions => ["is_in_roadmap=?", true]) | |
275 | retrieve_selected_tracker_ids(@trackers) |
|
276 | retrieve_selected_tracker_ids(@trackers) | |
276 | @versions = @project.versions.sort |
|
277 | @versions = @project.versions.sort | |
277 | @versions = @versions.select {|v| !v.completed? } unless params[:completed] |
|
278 | @versions = @versions.select {|v| !v.completed? } unless params[:completed] | |
278 | end |
|
279 | end | |
279 |
|
280 | |||
280 | def activity |
|
281 | def activity | |
281 | @days = Setting.activity_days_default.to_i |
|
282 | @days = Setting.activity_days_default.to_i | |
282 |
|
283 | |||
283 | if params[:from] |
|
284 | if params[:from] | |
284 | begin; @date_to = params[:from].to_date + 1; rescue; end |
|
285 | begin; @date_to = params[:from].to_date + 1; rescue; end | |
285 | end |
|
286 | end | |
286 |
|
287 | |||
287 | @date_to ||= Date.today + 1 |
|
288 | @date_to ||= Date.today + 1 | |
288 | @date_from = @date_to - @days |
|
289 | @date_from = @date_to - @days | |
289 | @with_subprojects = params[:with_subprojects].nil? ? Setting.display_subprojects_issues? : (params[:with_subprojects] == '1') |
|
290 | @with_subprojects = params[:with_subprojects].nil? ? Setting.display_subprojects_issues? : (params[:with_subprojects] == '1') | |
290 | @author = (params[:user_id].blank? ? nil : User.active.find(params[:user_id])) |
|
291 | @author = (params[:user_id].blank? ? nil : User.active.find(params[:user_id])) | |
291 |
|
292 | |||
292 | @activity = Redmine::Activity::Fetcher.new(User.current, :project => @project, |
|
293 | @activity = Redmine::Activity::Fetcher.new(User.current, :project => @project, | |
293 | :with_subprojects => @with_subprojects, |
|
294 | :with_subprojects => @with_subprojects, | |
294 | :author => @author) |
|
295 | :author => @author) | |
295 | @activity.scope_select {|t| !params["show_#{t}"].nil?} |
|
296 | @activity.scope_select {|t| !params["show_#{t}"].nil?} | |
296 | @activity.scope = (@author.nil? ? :default : :all) if @activity.scope.empty? |
|
297 | @activity.scope = (@author.nil? ? :default : :all) if @activity.scope.empty? | |
297 |
|
298 | |||
298 | events = @activity.events(@date_from, @date_to) |
|
299 | events = @activity.events(@date_from, @date_to) | |
299 |
|
300 | |||
300 | respond_to do |format| |
|
301 | respond_to do |format| | |
301 | format.html { |
|
302 | format.html { | |
302 | @events_by_day = events.group_by(&:event_date) |
|
303 | @events_by_day = events.group_by(&:event_date) | |
303 | render :layout => false if request.xhr? |
|
304 | render :layout => false if request.xhr? | |
304 | } |
|
305 | } | |
305 | format.atom { |
|
306 | format.atom { | |
306 | title = l(:label_activity) |
|
307 | title = l(:label_activity) | |
307 | if @author |
|
308 | if @author | |
308 | title = @author.name |
|
309 | title = @author.name | |
309 | elsif @activity.scope.size == 1 |
|
310 | elsif @activity.scope.size == 1 | |
310 | title = l("label_#{@activity.scope.first.singularize}_plural") |
|
311 | title = l("label_#{@activity.scope.first.singularize}_plural") | |
311 | end |
|
312 | end | |
312 | render_feed(events, :title => "#{@project || Setting.app_title}: #{title}") |
|
313 | render_feed(events, :title => "#{@project || Setting.app_title}: #{title}") | |
313 | } |
|
314 | } | |
314 | end |
|
315 | end | |
315 |
|
316 | |||
316 | rescue ActiveRecord::RecordNotFound |
|
317 | rescue ActiveRecord::RecordNotFound | |
317 | render_404 |
|
318 | render_404 | |
318 | end |
|
319 | end | |
319 |
|
320 | |||
320 | private |
|
321 | private | |
321 | # Find project of id params[:id] |
|
322 | # Find project of id params[:id] | |
322 | # if not found, redirect to project list |
|
323 | # if not found, redirect to project list | |
323 | # Used as a before_filter |
|
324 | # Used as a before_filter | |
324 | def find_project |
|
325 | def find_project | |
325 | @project = Project.find(params[:id]) |
|
326 | @project = Project.find(params[:id]) | |
326 | rescue ActiveRecord::RecordNotFound |
|
327 | rescue ActiveRecord::RecordNotFound | |
327 | render_404 |
|
328 | render_404 | |
328 | end |
|
329 | end | |
329 |
|
330 | |||
330 | def find_optional_project |
|
331 | def find_optional_project | |
331 | return true unless params[:id] |
|
332 | return true unless params[:id] | |
332 | @project = Project.find(params[:id]) |
|
333 | @project = Project.find(params[:id]) | |
333 | authorize |
|
334 | authorize | |
334 | rescue ActiveRecord::RecordNotFound |
|
335 | rescue ActiveRecord::RecordNotFound | |
335 | render_404 |
|
336 | render_404 | |
336 | end |
|
337 | end | |
337 |
|
338 | |||
338 | def retrieve_selected_tracker_ids(selectable_trackers) |
|
339 | def retrieve_selected_tracker_ids(selectable_trackers) | |
339 | if ids = params[:tracker_ids] |
|
340 | if ids = params[:tracker_ids] | |
340 | @selected_tracker_ids = (ids.is_a? Array) ? ids.collect { |id| id.to_i.to_s } : ids.split('/').collect { |id| id.to_i.to_s } |
|
341 | @selected_tracker_ids = (ids.is_a? Array) ? ids.collect { |id| id.to_i.to_s } : ids.split('/').collect { |id| id.to_i.to_s } | |
341 | else |
|
342 | else | |
342 | @selected_tracker_ids = selectable_trackers.collect {|t| t.id.to_s } |
|
343 | @selected_tracker_ids = selectable_trackers.collect {|t| t.id.to_s } | |
343 | end |
|
344 | end | |
344 | end |
|
345 | end | |
345 | end |
|
346 | end |
General Comments 0
You need to be logged in to leave comments.
Login now