##// END OF EJS Templates
Activity view improvements:...
Jean-Philippe Lang -
r640:2f0edb0b61aa
parent child
Show More
@@ -1,662 +1,672
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 require 'csv'
18 require 'csv'
19
19
20 class ProjectsController < ApplicationController
20 class ProjectsController < ApplicationController
21 layout 'base'
21 layout 'base'
22 before_filter :find_project, :except => [ :index, :list, :add ]
22 before_filter :find_project, :except => [ :index, :list, :add ]
23 before_filter :authorize, :except => [ :index, :list, :add, :archive, :unarchive, :destroy ]
23 before_filter :authorize, :except => [ :index, :list, :add, :archive, :unarchive, :destroy ]
24 before_filter :require_admin, :only => [ :add, :archive, :unarchive, :destroy ]
24 before_filter :require_admin, :only => [ :add, :archive, :unarchive, :destroy ]
25
25
26 cache_sweeper :project_sweeper, :only => [ :add, :edit, :archive, :unarchive, :destroy ]
26 cache_sweeper :project_sweeper, :only => [ :add, :edit, :archive, :unarchive, :destroy ]
27 cache_sweeper :issue_sweeper, :only => [ :add_issue ]
27 cache_sweeper :issue_sweeper, :only => [ :add_issue ]
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 IssuesHelper
35 helper IssuesHelper
36 helper :queries
36 helper :queries
37 include QueriesHelper
37 include QueriesHelper
38 helper :repositories
38 helper :repositories
39 include RepositoriesHelper
39 include RepositoriesHelper
40
40
41 def index
41 def index
42 list
42 list
43 render :action => 'list' unless request.xhr?
43 render :action => 'list' unless request.xhr?
44 end
44 end
45
45
46 # Lists public projects
46 # Lists public projects
47 def list
47 def list
48 sort_init "#{Project.table_name}.name", "asc"
48 sort_init "#{Project.table_name}.name", "asc"
49 sort_update
49 sort_update
50 @project_count = Project.count(:all, :conditions => Project.visible_by(logged_in_user))
50 @project_count = Project.count(:all, :conditions => Project.visible_by(logged_in_user))
51 @project_pages = Paginator.new self, @project_count,
51 @project_pages = Paginator.new self, @project_count,
52 15,
52 15,
53 params['page']
53 params['page']
54 @projects = Project.find :all, :order => sort_clause,
54 @projects = Project.find :all, :order => sort_clause,
55 :conditions => Project.visible_by(logged_in_user),
55 :conditions => Project.visible_by(logged_in_user),
56 :include => :parent,
56 :include => :parent,
57 :limit => @project_pages.items_per_page,
57 :limit => @project_pages.items_per_page,
58 :offset => @project_pages.current.offset
58 :offset => @project_pages.current.offset
59
59
60 render :action => "list", :layout => false if request.xhr?
60 render :action => "list", :layout => false if request.xhr?
61 end
61 end
62
62
63 # Add a new project
63 # Add a new project
64 def add
64 def add
65 @custom_fields = IssueCustomField.find(:all)
65 @custom_fields = IssueCustomField.find(:all)
66 @root_projects = Project.find(:all, :conditions => "parent_id is null")
66 @root_projects = Project.find(:all, :conditions => "parent_id is null")
67 @project = Project.new(params[:project])
67 @project = Project.new(params[:project])
68 if request.get?
68 if request.get?
69 @custom_values = ProjectCustomField.find(:all).collect { |x| CustomValue.new(:custom_field => x, :customized => @project) }
69 @custom_values = ProjectCustomField.find(:all).collect { |x| CustomValue.new(:custom_field => x, :customized => @project) }
70 else
70 else
71 @project.custom_fields = CustomField.find(params[:custom_field_ids]) if params[:custom_field_ids]
71 @project.custom_fields = CustomField.find(params[:custom_field_ids]) if params[:custom_field_ids]
72 @custom_values = ProjectCustomField.find(:all).collect { |x| CustomValue.new(:custom_field => x, :customized => @project, :value => params["custom_fields"][x.id.to_s]) }
72 @custom_values = ProjectCustomField.find(:all).collect { |x| CustomValue.new(:custom_field => x, :customized => @project, :value => params["custom_fields"][x.id.to_s]) }
73 @project.custom_values = @custom_values
73 @project.custom_values = @custom_values
74 if params[:repository_enabled] && params[:repository_enabled] == "1"
74 if params[:repository_enabled] && params[:repository_enabled] == "1"
75 @project.repository = Repository.factory(params[:repository_scm])
75 @project.repository = Repository.factory(params[:repository_scm])
76 @project.repository.attributes = params[:repository]
76 @project.repository.attributes = params[:repository]
77 end
77 end
78 if "1" == params[:wiki_enabled]
78 if "1" == params[:wiki_enabled]
79 @project.wiki = Wiki.new
79 @project.wiki = Wiki.new
80 @project.wiki.attributes = params[:wiki]
80 @project.wiki.attributes = params[:wiki]
81 end
81 end
82 if @project.save
82 if @project.save
83 flash[:notice] = l(:notice_successful_create)
83 flash[:notice] = l(:notice_successful_create)
84 redirect_to :controller => 'admin', :action => 'projects'
84 redirect_to :controller => 'admin', :action => 'projects'
85 end
85 end
86 end
86 end
87 end
87 end
88
88
89 # Show @project
89 # Show @project
90 def show
90 def show
91 @custom_values = @project.custom_values.find(:all, :include => :custom_field)
91 @custom_values = @project.custom_values.find(:all, :include => :custom_field)
92 @members_by_role = @project.members.find(:all, :include => [:user, :role], :order => 'position').group_by {|m| m.role}
92 @members_by_role = @project.members.find(:all, :include => [:user, :role], :order => 'position').group_by {|m| m.role}
93 @subprojects = @project.active_children
93 @subprojects = @project.active_children
94 @news = @project.news.find(:all, :limit => 5, :include => [ :author, :project ], :order => "#{News.table_name}.created_on DESC")
94 @news = @project.news.find(:all, :limit => 5, :include => [ :author, :project ], :order => "#{News.table_name}.created_on DESC")
95 @trackers = Tracker.find(:all, :order => 'position')
95 @trackers = Tracker.find(:all, :order => 'position')
96 @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])
96 @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])
97 @total_issues_by_tracker = Issue.count(:group => :tracker, :conditions => ["project_id=?", @project.id])
97 @total_issues_by_tracker = Issue.count(:group => :tracker, :conditions => ["project_id=?", @project.id])
98 end
98 end
99
99
100 def settings
100 def settings
101 @root_projects = Project::find(:all, :conditions => ["parent_id is null and id <> ?", @project.id])
101 @root_projects = Project::find(:all, :conditions => ["parent_id is null and id <> ?", @project.id])
102 @custom_fields = IssueCustomField.find(:all)
102 @custom_fields = IssueCustomField.find(:all)
103 @issue_category ||= IssueCategory.new
103 @issue_category ||= IssueCategory.new
104 @member ||= @project.members.new
104 @member ||= @project.members.new
105 @custom_values ||= ProjectCustomField.find(:all).collect { |x| @project.custom_values.find_by_custom_field_id(x.id) || CustomValue.new(:custom_field => x) }
105 @custom_values ||= ProjectCustomField.find(:all).collect { |x| @project.custom_values.find_by_custom_field_id(x.id) || CustomValue.new(:custom_field => x) }
106 end
106 end
107
107
108 # Edit @project
108 # Edit @project
109 def edit
109 def edit
110 if request.post?
110 if request.post?
111 @project.custom_fields = IssueCustomField.find(params[:custom_field_ids]) if params[:custom_field_ids]
111 @project.custom_fields = IssueCustomField.find(params[:custom_field_ids]) if params[:custom_field_ids]
112 if params[:custom_fields]
112 if params[:custom_fields]
113 @custom_values = ProjectCustomField.find(:all).collect { |x| CustomValue.new(:custom_field => x, :customized => @project, :value => params["custom_fields"][x.id.to_s]) }
113 @custom_values = ProjectCustomField.find(:all).collect { |x| CustomValue.new(:custom_field => x, :customized => @project, :value => params["custom_fields"][x.id.to_s]) }
114 @project.custom_values = @custom_values
114 @project.custom_values = @custom_values
115 end
115 end
116 if params[:repository_enabled]
116 if params[:repository_enabled]
117 case params[:repository_enabled]
117 case params[:repository_enabled]
118 when "0"
118 when "0"
119 @project.repository = nil
119 @project.repository = nil
120 when "1"
120 when "1"
121 @project.repository ||= Repository.factory(params[:repository_scm])
121 @project.repository ||= Repository.factory(params[:repository_scm])
122 @project.repository.update_attributes params[:repository] if @project.repository
122 @project.repository.update_attributes params[:repository] if @project.repository
123 end
123 end
124 end
124 end
125 if params[:wiki_enabled]
125 if params[:wiki_enabled]
126 case params[:wiki_enabled]
126 case params[:wiki_enabled]
127 when "0"
127 when "0"
128 @project.wiki.destroy if @project.wiki
128 @project.wiki.destroy if @project.wiki
129 when "1"
129 when "1"
130 @project.wiki ||= Wiki.new
130 @project.wiki ||= Wiki.new
131 @project.wiki.update_attributes params[:wiki]
131 @project.wiki.update_attributes params[:wiki]
132 end
132 end
133 end
133 end
134 @project.attributes = params[:project]
134 @project.attributes = params[:project]
135 if @project.save
135 if @project.save
136 flash[:notice] = l(:notice_successful_update)
136 flash[:notice] = l(:notice_successful_update)
137 redirect_to :action => 'settings', :id => @project
137 redirect_to :action => 'settings', :id => @project
138 else
138 else
139 settings
139 settings
140 render :action => 'settings'
140 render :action => 'settings'
141 end
141 end
142 end
142 end
143 end
143 end
144
144
145 def archive
145 def archive
146 @project.archive if request.post? && @project.active?
146 @project.archive if request.post? && @project.active?
147 redirect_to :controller => 'admin', :action => 'projects'
147 redirect_to :controller => 'admin', :action => 'projects'
148 end
148 end
149
149
150 def unarchive
150 def unarchive
151 @project.unarchive if request.post? && !@project.active?
151 @project.unarchive if request.post? && !@project.active?
152 redirect_to :controller => 'admin', :action => 'projects'
152 redirect_to :controller => 'admin', :action => 'projects'
153 end
153 end
154
154
155 # Delete @project
155 # Delete @project
156 def destroy
156 def destroy
157 @project_to_destroy = @project
157 @project_to_destroy = @project
158 if request.post? and params[:confirm]
158 if request.post? and params[:confirm]
159 @project_to_destroy.destroy
159 @project_to_destroy.destroy
160 redirect_to :controller => 'admin', :action => 'projects'
160 redirect_to :controller => 'admin', :action => 'projects'
161 end
161 end
162 # hide project in layout
162 # hide project in layout
163 @project = nil
163 @project = nil
164 end
164 end
165
165
166 # Add a new issue category to @project
166 # Add a new issue category to @project
167 def add_issue_category
167 def add_issue_category
168 @category = @project.issue_categories.build(params[:category])
168 @category = @project.issue_categories.build(params[:category])
169 if request.post? and @category.save
169 if request.post? and @category.save
170 flash[:notice] = l(:notice_successful_create)
170 flash[:notice] = l(:notice_successful_create)
171 redirect_to :action => 'settings', :tab => 'categories', :id => @project
171 redirect_to :action => 'settings', :tab => 'categories', :id => @project
172 end
172 end
173 end
173 end
174
174
175 # Add a new version to @project
175 # Add a new version to @project
176 def add_version
176 def add_version
177 @version = @project.versions.build(params[:version])
177 @version = @project.versions.build(params[:version])
178 if request.post? and @version.save
178 if request.post? and @version.save
179 flash[:notice] = l(:notice_successful_create)
179 flash[:notice] = l(:notice_successful_create)
180 redirect_to :action => 'settings', :tab => 'versions', :id => @project
180 redirect_to :action => 'settings', :tab => 'versions', :id => @project
181 end
181 end
182 end
182 end
183
183
184 # Add a new member to @project
184 # Add a new member to @project
185 def add_member
185 def add_member
186 @member = @project.members.build(params[:member])
186 @member = @project.members.build(params[:member])
187 if request.post? && @member.save
187 if request.post? && @member.save
188 respond_to do |format|
188 respond_to do |format|
189 format.html { redirect_to :action => 'settings', :tab => 'members', :id => @project }
189 format.html { redirect_to :action => 'settings', :tab => 'members', :id => @project }
190 format.js { render(:update) {|page| page.replace_html "tab-content-members", :partial => 'members'} }
190 format.js { render(:update) {|page| page.replace_html "tab-content-members", :partial => 'members'} }
191 end
191 end
192 else
192 else
193 settings
193 settings
194 render :action => 'settings'
194 render :action => 'settings'
195 end
195 end
196 end
196 end
197
197
198 # Show members list of @project
198 # Show members list of @project
199 def list_members
199 def list_members
200 @members = @project.members.find(:all)
200 @members = @project.members.find(:all)
201 end
201 end
202
202
203 # Add a new document to @project
203 # Add a new document to @project
204 def add_document
204 def add_document
205 @categories = Enumeration::get_values('DCAT')
205 @categories = Enumeration::get_values('DCAT')
206 @document = @project.documents.build(params[:document])
206 @document = @project.documents.build(params[:document])
207 if request.post? and @document.save
207 if request.post? and @document.save
208 # Save the attachments
208 # Save the attachments
209 params[:attachments].each { |a|
209 params[:attachments].each { |a|
210 Attachment.create(:container => @document, :file => a, :author => logged_in_user) unless a.size == 0
210 Attachment.create(:container => @document, :file => a, :author => logged_in_user) unless a.size == 0
211 } if params[:attachments] and params[:attachments].is_a? Array
211 } if params[:attachments] and params[:attachments].is_a? Array
212 flash[:notice] = l(:notice_successful_create)
212 flash[:notice] = l(:notice_successful_create)
213 Mailer.deliver_document_add(@document) if Permission.find_by_controller_and_action(params[:controller], params[:action]).mail_enabled?
213 Mailer.deliver_document_add(@document) if Permission.find_by_controller_and_action(params[:controller], params[:action]).mail_enabled?
214 redirect_to :action => 'list_documents', :id => @project
214 redirect_to :action => 'list_documents', :id => @project
215 end
215 end
216 end
216 end
217
217
218 # Show documents list of @project
218 # Show documents list of @project
219 def list_documents
219 def list_documents
220 @documents = @project.documents.find :all, :include => :category
220 @documents = @project.documents.find :all, :include => :category
221 end
221 end
222
222
223 # Add a new issue to @project
223 # Add a new issue to @project
224 def add_issue
224 def add_issue
225 @tracker = Tracker.find(params[:tracker_id])
225 @tracker = Tracker.find(params[:tracker_id])
226 @priorities = Enumeration::get_values('IPRI')
226 @priorities = Enumeration::get_values('IPRI')
227
227
228 default_status = IssueStatus.default
228 default_status = IssueStatus.default
229 unless default_status
229 unless default_status
230 flash.now[:error] = 'No default issue status defined. Please check your configuration.'
230 flash.now[:error] = 'No default issue status defined. Please check your configuration.'
231 render :nothing => true, :layout => true
231 render :nothing => true, :layout => true
232 return
232 return
233 end
233 end
234 @issue = Issue.new(:project => @project, :tracker => @tracker)
234 @issue = Issue.new(:project => @project, :tracker => @tracker)
235 @issue.status = default_status
235 @issue.status = default_status
236 @allowed_statuses = ([default_status] + default_status.find_new_statuses_allowed_to(logged_in_user.role_for_project(@project), @issue.tracker))if logged_in_user
236 @allowed_statuses = ([default_status] + default_status.find_new_statuses_allowed_to(logged_in_user.role_for_project(@project), @issue.tracker))if logged_in_user
237 if request.get?
237 if request.get?
238 @issue.start_date = Date.today
238 @issue.start_date = Date.today
239 @custom_values = @project.custom_fields_for_issues(@tracker).collect { |x| CustomValue.new(:custom_field => x, :customized => @issue) }
239 @custom_values = @project.custom_fields_for_issues(@tracker).collect { |x| CustomValue.new(:custom_field => x, :customized => @issue) }
240 else
240 else
241 @issue.attributes = params[:issue]
241 @issue.attributes = params[:issue]
242
242
243 requested_status = IssueStatus.find_by_id(params[:issue][:status_id])
243 requested_status = IssueStatus.find_by_id(params[:issue][:status_id])
244 @issue.status = (@allowed_statuses.include? requested_status) ? requested_status : default_status
244 @issue.status = (@allowed_statuses.include? requested_status) ? requested_status : default_status
245
245
246 @issue.author_id = self.logged_in_user.id if self.logged_in_user
246 @issue.author_id = self.logged_in_user.id if self.logged_in_user
247 # Multiple file upload
247 # Multiple file upload
248 @attachments = []
248 @attachments = []
249 params[:attachments].each { |a|
249 params[:attachments].each { |a|
250 @attachments << Attachment.new(:container => @issue, :file => a, :author => logged_in_user) unless a.size == 0
250 @attachments << Attachment.new(:container => @issue, :file => a, :author => logged_in_user) unless a.size == 0
251 } if params[:attachments] and params[:attachments].is_a? Array
251 } if params[:attachments] and params[:attachments].is_a? Array
252 @custom_values = @project.custom_fields_for_issues(@tracker).collect { |x| CustomValue.new(:custom_field => x, :customized => @issue, :value => params["custom_fields"][x.id.to_s]) }
252 @custom_values = @project.custom_fields_for_issues(@tracker).collect { |x| CustomValue.new(:custom_field => x, :customized => @issue, :value => params["custom_fields"][x.id.to_s]) }
253 @issue.custom_values = @custom_values
253 @issue.custom_values = @custom_values
254 if @issue.save
254 if @issue.save
255 @attachments.each(&:save)
255 @attachments.each(&:save)
256 flash[:notice] = l(:notice_successful_create)
256 flash[:notice] = l(:notice_successful_create)
257 Mailer.deliver_issue_add(@issue) if Permission.find_by_controller_and_action(params[:controller], params[:action]).mail_enabled?
257 Mailer.deliver_issue_add(@issue) if Permission.find_by_controller_and_action(params[:controller], params[:action]).mail_enabled?
258 redirect_to :action => 'list_issues', :id => @project
258 redirect_to :action => 'list_issues', :id => @project
259 end
259 end
260 end
260 end
261 end
261 end
262
262
263 # Show filtered/sorted issues list of @project
263 # Show filtered/sorted issues list of @project
264 def list_issues
264 def list_issues
265 sort_init "#{Issue.table_name}.id", "desc"
265 sort_init "#{Issue.table_name}.id", "desc"
266 sort_update
266 sort_update
267
267
268 retrieve_query
268 retrieve_query
269
269
270 @results_per_page_options = [ 15, 25, 50, 100 ]
270 @results_per_page_options = [ 15, 25, 50, 100 ]
271 if params[:per_page] and @results_per_page_options.include? params[:per_page].to_i
271 if params[:per_page] and @results_per_page_options.include? params[:per_page].to_i
272 @results_per_page = params[:per_page].to_i
272 @results_per_page = params[:per_page].to_i
273 session[:results_per_page] = @results_per_page
273 session[:results_per_page] = @results_per_page
274 else
274 else
275 @results_per_page = session[:results_per_page] || 25
275 @results_per_page = session[:results_per_page] || 25
276 end
276 end
277
277
278 if @query.valid?
278 if @query.valid?
279 @issue_count = Issue.count(:include => [:status, :project, :custom_values], :conditions => @query.statement)
279 @issue_count = Issue.count(:include => [:status, :project, :custom_values], :conditions => @query.statement)
280 @issue_pages = Paginator.new self, @issue_count, @results_per_page, params['page']
280 @issue_pages = Paginator.new self, @issue_count, @results_per_page, params['page']
281 @issues = Issue.find :all, :order => sort_clause,
281 @issues = Issue.find :all, :order => sort_clause,
282 :include => [ :assigned_to, :status, :tracker, :project, :priority, :custom_values ],
282 :include => [ :assigned_to, :status, :tracker, :project, :priority, :custom_values ],
283 :conditions => @query.statement,
283 :conditions => @query.statement,
284 :limit => @issue_pages.items_per_page,
284 :limit => @issue_pages.items_per_page,
285 :offset => @issue_pages.current.offset
285 :offset => @issue_pages.current.offset
286 end
286 end
287 render :layout => false if request.xhr?
287 render :layout => false if request.xhr?
288 end
288 end
289
289
290 # Export filtered/sorted issues list to CSV
290 # Export filtered/sorted issues list to CSV
291 def export_issues_csv
291 def export_issues_csv
292 sort_init "#{Issue.table_name}.id", "desc"
292 sort_init "#{Issue.table_name}.id", "desc"
293 sort_update
293 sort_update
294
294
295 retrieve_query
295 retrieve_query
296 render :action => 'list_issues' and return unless @query.valid?
296 render :action => 'list_issues' and return unless @query.valid?
297
297
298 @issues = Issue.find :all, :order => sort_clause,
298 @issues = Issue.find :all, :order => sort_clause,
299 :include => [ :assigned_to, :author, :status, :tracker, :priority, :project, {:custom_values => :custom_field} ],
299 :include => [ :assigned_to, :author, :status, :tracker, :priority, :project, {:custom_values => :custom_field} ],
300 :conditions => @query.statement,
300 :conditions => @query.statement,
301 :limit => Setting.issues_export_limit.to_i
301 :limit => Setting.issues_export_limit.to_i
302
302
303 ic = Iconv.new(l(:general_csv_encoding), 'UTF-8')
303 ic = Iconv.new(l(:general_csv_encoding), 'UTF-8')
304 export = StringIO.new
304 export = StringIO.new
305 CSV::Writer.generate(export, l(:general_csv_separator)) do |csv|
305 CSV::Writer.generate(export, l(:general_csv_separator)) do |csv|
306 # csv header fields
306 # csv header fields
307 headers = [ "#", l(:field_status),
307 headers = [ "#", l(:field_status),
308 l(:field_project),
308 l(:field_project),
309 l(:field_tracker),
309 l(:field_tracker),
310 l(:field_priority),
310 l(:field_priority),
311 l(:field_subject),
311 l(:field_subject),
312 l(:field_assigned_to),
312 l(:field_assigned_to),
313 l(:field_author),
313 l(:field_author),
314 l(:field_start_date),
314 l(:field_start_date),
315 l(:field_due_date),
315 l(:field_due_date),
316 l(:field_done_ratio),
316 l(:field_done_ratio),
317 l(:field_created_on),
317 l(:field_created_on),
318 l(:field_updated_on)
318 l(:field_updated_on)
319 ]
319 ]
320 for custom_field in @project.all_custom_fields
320 for custom_field in @project.all_custom_fields
321 headers << custom_field.name
321 headers << custom_field.name
322 end
322 end
323 csv << headers.collect {|c| begin; ic.iconv(c.to_s); rescue; c.to_s; end }
323 csv << headers.collect {|c| begin; ic.iconv(c.to_s); rescue; c.to_s; end }
324 # csv lines
324 # csv lines
325 @issues.each do |issue|
325 @issues.each do |issue|
326 fields = [issue.id, issue.status.name,
326 fields = [issue.id, issue.status.name,
327 issue.project.name,
327 issue.project.name,
328 issue.tracker.name,
328 issue.tracker.name,
329 issue.priority.name,
329 issue.priority.name,
330 issue.subject,
330 issue.subject,
331 (issue.assigned_to ? issue.assigned_to.name : ""),
331 (issue.assigned_to ? issue.assigned_to.name : ""),
332 issue.author.name,
332 issue.author.name,
333 issue.start_date ? l_date(issue.start_date) : nil,
333 issue.start_date ? l_date(issue.start_date) : nil,
334 issue.due_date ? l_date(issue.due_date) : nil,
334 issue.due_date ? l_date(issue.due_date) : nil,
335 issue.done_ratio,
335 issue.done_ratio,
336 l_datetime(issue.created_on),
336 l_datetime(issue.created_on),
337 l_datetime(issue.updated_on)
337 l_datetime(issue.updated_on)
338 ]
338 ]
339 for custom_field in @project.all_custom_fields
339 for custom_field in @project.all_custom_fields
340 fields << (show_value issue.custom_value_for(custom_field))
340 fields << (show_value issue.custom_value_for(custom_field))
341 end
341 end
342 csv << fields.collect {|c| begin; ic.iconv(c.to_s); rescue; c.to_s; end }
342 csv << fields.collect {|c| begin; ic.iconv(c.to_s); rescue; c.to_s; end }
343 end
343 end
344 end
344 end
345 export.rewind
345 export.rewind
346 send_data(export.read, :type => 'text/csv; header=present', :filename => 'export.csv')
346 send_data(export.read, :type => 'text/csv; header=present', :filename => 'export.csv')
347 end
347 end
348
348
349 # Export filtered/sorted issues to PDF
349 # Export filtered/sorted issues to PDF
350 def export_issues_pdf
350 def export_issues_pdf
351 sort_init "#{Issue.table_name}.id", "desc"
351 sort_init "#{Issue.table_name}.id", "desc"
352 sort_update
352 sort_update
353
353
354 retrieve_query
354 retrieve_query
355 render :action => 'list_issues' and return unless @query.valid?
355 render :action => 'list_issues' and return unless @query.valid?
356
356
357 @issues = Issue.find :all, :order => sort_clause,
357 @issues = Issue.find :all, :order => sort_clause,
358 :include => [ :author, :status, :tracker, :priority, :project, :custom_values ],
358 :include => [ :author, :status, :tracker, :priority, :project, :custom_values ],
359 :conditions => @query.statement,
359 :conditions => @query.statement,
360 :limit => Setting.issues_export_limit.to_i
360 :limit => Setting.issues_export_limit.to_i
361
361
362 @options_for_rfpdf ||= {}
362 @options_for_rfpdf ||= {}
363 @options_for_rfpdf[:file_name] = "export.pdf"
363 @options_for_rfpdf[:file_name] = "export.pdf"
364 render :layout => false
364 render :layout => false
365 end
365 end
366
366
367 def move_issues
367 def move_issues
368 @issues = @project.issues.find(params[:issue_ids]) if params[:issue_ids]
368 @issues = @project.issues.find(params[:issue_ids]) if params[:issue_ids]
369 redirect_to :action => 'list_issues', :id => @project and return unless @issues
369 redirect_to :action => 'list_issues', :id => @project and return unless @issues
370 @projects = []
370 @projects = []
371 # find projects to which the user is allowed to move the issue
371 # find projects to which the user is allowed to move the issue
372 @logged_in_user.memberships.each {|m| @projects << m.project if Permission.allowed_to_role("projects/move_issues", m.role)}
372 @logged_in_user.memberships.each {|m| @projects << m.project if Permission.allowed_to_role("projects/move_issues", m.role)}
373 # issue can be moved to any tracker
373 # issue can be moved to any tracker
374 @trackers = Tracker.find(:all)
374 @trackers = Tracker.find(:all)
375 if request.post? and params[:new_project_id] and params[:new_tracker_id]
375 if request.post? and params[:new_project_id] and params[:new_tracker_id]
376 new_project = Project.find(params[:new_project_id])
376 new_project = Project.find(params[:new_project_id])
377 new_tracker = Tracker.find(params[:new_tracker_id])
377 new_tracker = Tracker.find(params[:new_tracker_id])
378 @issues.each { |i|
378 @issues.each { |i|
379 # project dependent properties
379 # project dependent properties
380 unless i.project_id == new_project.id
380 unless i.project_id == new_project.id
381 i.category = nil
381 i.category = nil
382 i.fixed_version = nil
382 i.fixed_version = nil
383 # delete issue relations
383 # delete issue relations
384 i.relations_from.clear
384 i.relations_from.clear
385 i.relations_to.clear
385 i.relations_to.clear
386 end
386 end
387 # move the issue
387 # move the issue
388 i.project = new_project
388 i.project = new_project
389 i.tracker = new_tracker
389 i.tracker = new_tracker
390 i.save
390 i.save
391 }
391 }
392 flash[:notice] = l(:notice_successful_update)
392 flash[:notice] = l(:notice_successful_update)
393 redirect_to :action => 'list_issues', :id => @project
393 redirect_to :action => 'list_issues', :id => @project
394 end
394 end
395 end
395 end
396
396
397 # Add a news to @project
397 # Add a news to @project
398 def add_news
398 def add_news
399 @news = News.new(:project => @project)
399 @news = News.new(:project => @project)
400 if request.post?
400 if request.post?
401 @news.attributes = params[:news]
401 @news.attributes = params[:news]
402 @news.author_id = self.logged_in_user.id if self.logged_in_user
402 @news.author_id = self.logged_in_user.id if self.logged_in_user
403 if @news.save
403 if @news.save
404 flash[:notice] = l(:notice_successful_create)
404 flash[:notice] = l(:notice_successful_create)
405 redirect_to :action => 'list_news', :id => @project
405 redirect_to :action => 'list_news', :id => @project
406 end
406 end
407 end
407 end
408 end
408 end
409
409
410 # Show news list of @project
410 # Show news list of @project
411 def list_news
411 def list_news
412 @news_pages, @news = paginate :news, :per_page => 10, :conditions => ["project_id=?", @project.id], :include => :author, :order => "#{News.table_name}.created_on DESC"
412 @news_pages, @news = paginate :news, :per_page => 10, :conditions => ["project_id=?", @project.id], :include => :author, :order => "#{News.table_name}.created_on DESC"
413 render :action => "list_news", :layout => false if request.xhr?
413 render :action => "list_news", :layout => false if request.xhr?
414 end
414 end
415
415
416 def add_file
416 def add_file
417 if request.post?
417 if request.post?
418 @version = @project.versions.find_by_id(params[:version_id])
418 @version = @project.versions.find_by_id(params[:version_id])
419 # Save the attachments
419 # Save the attachments
420 @attachments = []
420 @attachments = []
421 params[:attachments].each { |file|
421 params[:attachments].each { |file|
422 next unless file.size > 0
422 next unless file.size > 0
423 a = Attachment.create(:container => @version, :file => file, :author => logged_in_user)
423 a = Attachment.create(:container => @version, :file => file, :author => logged_in_user)
424 @attachments << a unless a.new_record?
424 @attachments << a unless a.new_record?
425 } if params[:attachments] and params[:attachments].is_a? Array
425 } if params[:attachments] and params[:attachments].is_a? Array
426 Mailer.deliver_attachments_add(@attachments) if !@attachments.empty? and Permission.find_by_controller_and_action(params[:controller], params[:action]).mail_enabled?
426 Mailer.deliver_attachments_add(@attachments) if !@attachments.empty? and Permission.find_by_controller_and_action(params[:controller], params[:action]).mail_enabled?
427 redirect_to :controller => 'projects', :action => 'list_files', :id => @project
427 redirect_to :controller => 'projects', :action => 'list_files', :id => @project
428 end
428 end
429 @versions = @project.versions.sort
429 @versions = @project.versions.sort
430 end
430 end
431
431
432 def list_files
432 def list_files
433 @versions = @project.versions.sort
433 @versions = @project.versions.sort
434 end
434 end
435
435
436 # Show changelog for @project
436 # Show changelog for @project
437 def changelog
437 def changelog
438 @trackers = Tracker.find(:all, :conditions => ["is_in_chlog=?", true], :order => 'position')
438 @trackers = Tracker.find(:all, :conditions => ["is_in_chlog=?", true], :order => 'position')
439 retrieve_selected_tracker_ids(@trackers)
439 retrieve_selected_tracker_ids(@trackers)
440 @versions = @project.versions.sort
440 @versions = @project.versions.sort
441 end
441 end
442
442
443 def roadmap
443 def roadmap
444 @trackers = Tracker.find(:all, :conditions => ["is_in_roadmap=?", true], :order => 'position')
444 @trackers = Tracker.find(:all, :conditions => ["is_in_roadmap=?", true], :order => 'position')
445 retrieve_selected_tracker_ids(@trackers)
445 retrieve_selected_tracker_ids(@trackers)
446 @versions = @project.versions.sort
446 @versions = @project.versions.sort
447 @versions = @versions.select {|v| !v.completed? } unless params[:completed]
447 @versions = @versions.select {|v| !v.completed? } unless params[:completed]
448 end
448 end
449
449
450 def activity
450 def activity
451 if params[:year] and params[:year].to_i > 1900
451 if params[:year] and params[:year].to_i > 1900
452 @year = params[:year].to_i
452 @year = params[:year].to_i
453 if params[:month] and params[:month].to_i > 0 and params[:month].to_i < 13
453 if params[:month] and params[:month].to_i > 0 and params[:month].to_i < 13
454 @month = params[:month].to_i
454 @month = params[:month].to_i
455 end
455 end
456 end
456 end
457 @year ||= Date.today.year
457 @year ||= Date.today.year
458 @month ||= Date.today.month
458 @month ||= Date.today.month
459
459
460 @date_from = Date.civil(@year, @month, 1)
460 @date_from = Date.civil(@year, @month, 1)
461 @date_to = @date_from >> 1
461 @date_to = @date_from >> 1
462
462
463 @events_by_day = {}
463 @events_by_day = {}
464
464
465 unless params[:show_issues] == "0"
465 unless params[:show_issues] == "0"
466 @project.issues.find(:all, :include => [:author], :conditions => ["#{Issue.table_name}.created_on>=? and #{Issue.table_name}.created_on<=?", @date_from, @date_to] ).each { |i|
466 @project.issues.find(:all, :include => [:author], :conditions => ["#{Issue.table_name}.created_on BETWEEN ? AND ?", @date_from, @date_to] ).each { |i|
467 @events_by_day[i.created_on.to_date] ||= []
468 @events_by_day[i.created_on.to_date] << i
469 }
470 @project.issue_changes.find(:all, :include => :details, :conditions => ["(#{Journal.table_name}.created_on BETWEEN ? AND ?) AND (#{JournalDetail.table_name}.prop_key = 'status_id')", @date_from, @date_to] ).each { |i|
467 @events_by_day[i.created_on.to_date] ||= []
471 @events_by_day[i.created_on.to_date] ||= []
468 @events_by_day[i.created_on.to_date] << i
472 @events_by_day[i.created_on.to_date] << i
469 }
473 }
470 @show_issues = 1
474 @show_issues = 1
471 end
475 end
472
476
473 unless params[:show_news] == "0"
477 unless params[:show_news] == "0"
474 @project.news.find(:all, :conditions => ["#{News.table_name}.created_on>=? and #{News.table_name}.created_on<=?", @date_from, @date_to], :include => :author ).each { |i|
478 @project.news.find(:all, :conditions => ["#{News.table_name}.created_on BETWEEN ? AND ?", @date_from, @date_to], :include => :author ).each { |i|
475 @events_by_day[i.created_on.to_date] ||= []
479 @events_by_day[i.created_on.to_date] ||= []
476 @events_by_day[i.created_on.to_date] << i
480 @events_by_day[i.created_on.to_date] << i
477 }
481 }
478 @show_news = 1
482 @show_news = 1
479 end
483 end
480
484
481 unless params[:show_files] == "0"
485 unless params[:show_files] == "0"
482 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 ).each { |i|
486 Attachment.find(:all, :select => "#{Attachment.table_name}.*",
487 :joins => "LEFT JOIN #{Version.table_name} ON #{Version.table_name}.id = #{Attachment.table_name}.container_id",
488 :conditions => ["#{Attachment.table_name}.container_type='Version' and #{Version.table_name}.project_id=? and #{Attachment.table_name}.created_on BETWEEN ? AND ?", @project.id, @date_from, @date_to],
489 :include => :author ).each { |i|
483 @events_by_day[i.created_on.to_date] ||= []
490 @events_by_day[i.created_on.to_date] ||= []
484 @events_by_day[i.created_on.to_date] << i
491 @events_by_day[i.created_on.to_date] << i
485 }
492 }
486 @show_files = 1
493 @show_files = 1
487 end
494 end
488
495
489 unless params[:show_documents] == "0"
496 unless params[:show_documents] == "0"
490 @project.documents.find(:all, :conditions => ["#{Document.table_name}.created_on>=? and #{Document.table_name}.created_on<=?", @date_from, @date_to] ).each { |i|
497 @project.documents.find(:all, :conditions => ["#{Document.table_name}.created_on BETWEEN ? AND ?", @date_from, @date_to] ).each { |i|
491 @events_by_day[i.created_on.to_date] ||= []
498 @events_by_day[i.created_on.to_date] ||= []
492 @events_by_day[i.created_on.to_date] << i
499 @events_by_day[i.created_on.to_date] << i
493 }
500 }
494 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 ).each { |i|
501 Attachment.find(:all, :select => "attachments.*",
502 :joins => "LEFT JOIN #{Document.table_name} ON #{Document.table_name}.id = #{Attachment.table_name}.container_id",
503 :conditions => ["#{Attachment.table_name}.container_type='Document' and #{Document.table_name}.project_id=? and #{Attachment.table_name}.created_on BETWEEN ? AND ?", @project.id, @date_from, @date_to],
504 :include => :author ).each { |i|
495 @events_by_day[i.created_on.to_date] ||= []
505 @events_by_day[i.created_on.to_date] ||= []
496 @events_by_day[i.created_on.to_date] << i
506 @events_by_day[i.created_on.to_date] << i
497 }
507 }
498 @show_documents = 1
508 @show_documents = 1
499 end
509 end
500
510
501 unless @project.wiki.nil? || params[:show_wiki_edits] == "0"
511 unless @project.wiki.nil? || params[:show_wiki_edits] == "0"
502 select = "#{WikiContent.versioned_table_name}.updated_on, #{WikiContent.versioned_table_name}.comments, " +
512 select = "#{WikiContent.versioned_table_name}.updated_on, #{WikiContent.versioned_table_name}.comments, " +
503 "#{WikiContent.versioned_table_name}.#{WikiContent.version_column}, #{WikiPage.table_name}.title"
513 "#{WikiContent.versioned_table_name}.#{WikiContent.version_column}, #{WikiPage.table_name}.title"
504 joins = "LEFT JOIN #{WikiPage.table_name} ON #{WikiPage.table_name}.id = #{WikiContent.versioned_table_name}.page_id " +
514 joins = "LEFT JOIN #{WikiPage.table_name} ON #{WikiPage.table_name}.id = #{WikiContent.versioned_table_name}.page_id " +
505 "LEFT JOIN #{Wiki.table_name} ON #{Wiki.table_name}.id = #{WikiPage.table_name}.wiki_id "
515 "LEFT JOIN #{Wiki.table_name} ON #{Wiki.table_name}.id = #{WikiPage.table_name}.wiki_id "
506 conditions = ["#{Wiki.table_name}.project_id = ? AND #{WikiContent.versioned_table_name}.updated_on BETWEEN ? AND ?",
516 conditions = ["#{Wiki.table_name}.project_id = ? AND #{WikiContent.versioned_table_name}.updated_on BETWEEN ? AND ?",
507 @project.id, @date_from, @date_to]
517 @project.id, @date_from, @date_to]
508
518
509 WikiContent.versioned_class.find(:all, :select => select, :joins => joins, :conditions => conditions).each { |i|
519 WikiContent.versioned_class.find(:all, :select => select, :joins => joins, :conditions => conditions).each { |i|
510 # We provide this alias so all events can be treated in the same manner
520 # We provide this alias so all events can be treated in the same manner
511 def i.created_on
521 def i.created_on
512 self.updated_on
522 self.updated_on
513 end
523 end
514
524
515 @events_by_day[i.created_on.to_date] ||= []
525 @events_by_day[i.created_on.to_date] ||= []
516 @events_by_day[i.created_on.to_date] << i
526 @events_by_day[i.created_on.to_date] << i
517 }
527 }
518 @show_wiki_edits = 1
528 @show_wiki_edits = 1
519 end
529 end
520
530
521 unless @project.repository.nil? || params[:show_changesets] == "0"
531 unless @project.repository.nil? || params[:show_changesets] == "0"
522 @project.repository.changesets.find(:all, :conditions => ["#{Changeset.table_name}.committed_on BETWEEN ? AND ?", @date_from, @date_to]).each { |i|
532 @project.repository.changesets.find(:all, :conditions => ["#{Changeset.table_name}.committed_on BETWEEN ? AND ?", @date_from, @date_to]).each { |i|
523 def i.created_on
533 def i.created_on
524 self.committed_on
534 self.committed_on
525 end
535 end
526 @events_by_day[i.created_on.to_date] ||= []
536 @events_by_day[i.created_on.to_date] ||= []
527 @events_by_day[i.created_on.to_date] << i
537 @events_by_day[i.created_on.to_date] << i
528 }
538 }
529 @show_changesets = 1
539 @show_changesets = 1
530 end
540 end
531
541
532 render :layout => false if request.xhr?
542 render :layout => false if request.xhr?
533 end
543 end
534
544
535 def calendar
545 def calendar
536 @trackers = Tracker.find(:all, :order => 'position')
546 @trackers = Tracker.find(:all, :order => 'position')
537 retrieve_selected_tracker_ids(@trackers)
547 retrieve_selected_tracker_ids(@trackers)
538
548
539 if params[:year] and params[:year].to_i > 1900
549 if params[:year] and params[:year].to_i > 1900
540 @year = params[:year].to_i
550 @year = params[:year].to_i
541 if params[:month] and params[:month].to_i > 0 and params[:month].to_i < 13
551 if params[:month] and params[:month].to_i > 0 and params[:month].to_i < 13
542 @month = params[:month].to_i
552 @month = params[:month].to_i
543 end
553 end
544 end
554 end
545 @year ||= Date.today.year
555 @year ||= Date.today.year
546 @month ||= Date.today.month
556 @month ||= Date.today.month
547
557
548 @date_from = Date.civil(@year, @month, 1)
558 @date_from = Date.civil(@year, @month, 1)
549 @date_to = (@date_from >> 1)-1
559 @date_to = (@date_from >> 1)-1
550 # start on monday
560 # start on monday
551 @date_from = @date_from - (@date_from.cwday-1)
561 @date_from = @date_from - (@date_from.cwday-1)
552 # finish on sunday
562 # finish on sunday
553 @date_to = @date_to + (7-@date_to.cwday)
563 @date_to = @date_to + (7-@date_to.cwday)
554
564
555 @events = []
565 @events = []
556 @project.issues_with_subprojects(params[:with_subprojects]) do
566 @project.issues_with_subprojects(params[:with_subprojects]) do
557 @events += Issue.find(:all,
567 @events += Issue.find(:all,
558 :include => [:tracker, :status, :assigned_to, :priority, :project],
568 :include => [:tracker, :status, :assigned_to, :priority, :project],
559 :conditions => ["((start_date>=? and start_date<=?) or (due_date>=? and due_date<=?)) and #{Issue.table_name}.tracker_id in (#{@selected_tracker_ids.join(',')})", @date_from, @date_to, @date_from, @date_to]
569 :conditions => ["((start_date>=? and start_date<=?) or (due_date>=? and due_date<=?)) and #{Issue.table_name}.tracker_id in (#{@selected_tracker_ids.join(',')})", @date_from, @date_to, @date_from, @date_to]
560 ) unless @selected_tracker_ids.empty?
570 ) unless @selected_tracker_ids.empty?
561 end
571 end
562 @events += @project.versions.find(:all, :conditions => ["effective_date BETWEEN ? AND ?", @date_from, @date_to])
572 @events += @project.versions.find(:all, :conditions => ["effective_date BETWEEN ? AND ?", @date_from, @date_to])
563
573
564 @ending_events_by_days = @events.group_by {|event| event.due_date}
574 @ending_events_by_days = @events.group_by {|event| event.due_date}
565 @starting_events_by_days = @events.group_by {|event| event.start_date}
575 @starting_events_by_days = @events.group_by {|event| event.start_date}
566
576
567 render :layout => false if request.xhr?
577 render :layout => false if request.xhr?
568 end
578 end
569
579
570 def gantt
580 def gantt
571 @trackers = Tracker.find(:all, :order => 'position')
581 @trackers = Tracker.find(:all, :order => 'position')
572 retrieve_selected_tracker_ids(@trackers)
582 retrieve_selected_tracker_ids(@trackers)
573
583
574 if params[:year] and params[:year].to_i >0
584 if params[:year] and params[:year].to_i >0
575 @year_from = params[:year].to_i
585 @year_from = params[:year].to_i
576 if params[:month] and params[:month].to_i >=1 and params[:month].to_i <= 12
586 if params[:month] and params[:month].to_i >=1 and params[:month].to_i <= 12
577 @month_from = params[:month].to_i
587 @month_from = params[:month].to_i
578 else
588 else
579 @month_from = 1
589 @month_from = 1
580 end
590 end
581 else
591 else
582 @month_from ||= (Date.today << 1).month
592 @month_from ||= (Date.today << 1).month
583 @year_from ||= (Date.today << 1).year
593 @year_from ||= (Date.today << 1).year
584 end
594 end
585
595
586 @zoom = (params[:zoom].to_i > 0 and params[:zoom].to_i < 5) ? params[:zoom].to_i : 2
596 @zoom = (params[:zoom].to_i > 0 and params[:zoom].to_i < 5) ? params[:zoom].to_i : 2
587 @months = (params[:months].to_i > 0 and params[:months].to_i < 25) ? params[:months].to_i : 6
597 @months = (params[:months].to_i > 0 and params[:months].to_i < 25) ? params[:months].to_i : 6
588
598
589 @date_from = Date.civil(@year_from, @month_from, 1)
599 @date_from = Date.civil(@year_from, @month_from, 1)
590 @date_to = (@date_from >> @months) - 1
600 @date_to = (@date_from >> @months) - 1
591
601
592 @events = []
602 @events = []
593 @project.issues_with_subprojects(params[:with_subprojects]) do
603 @project.issues_with_subprojects(params[:with_subprojects]) do
594 @events += Issue.find(:all,
604 @events += Issue.find(:all,
595 :order => "start_date, due_date",
605 :order => "start_date, due_date",
596 :include => [:tracker, :status, :assigned_to, :priority, :project],
606 :include => [:tracker, :status, :assigned_to, :priority, :project],
597 :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]
607 :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]
598 ) unless @selected_tracker_ids.empty?
608 ) unless @selected_tracker_ids.empty?
599 end
609 end
600 @events += @project.versions.find(:all, :conditions => ["effective_date BETWEEN ? AND ?", @date_from, @date_to])
610 @events += @project.versions.find(:all, :conditions => ["effective_date BETWEEN ? AND ?", @date_from, @date_to])
601 @events.sort! {|x,y| x.start_date <=> y.start_date }
611 @events.sort! {|x,y| x.start_date <=> y.start_date }
602
612
603 if params[:output]=='pdf'
613 if params[:output]=='pdf'
604 @options_for_rfpdf ||= {}
614 @options_for_rfpdf ||= {}
605 @options_for_rfpdf[:file_name] = "gantt.pdf"
615 @options_for_rfpdf[:file_name] = "gantt.pdf"
606 render :template => "projects/gantt.rfpdf", :layout => false
616 render :template => "projects/gantt.rfpdf", :layout => false
607 else
617 else
608 render :template => "projects/gantt.rhtml"
618 render :template => "projects/gantt.rhtml"
609 end
619 end
610 end
620 end
611
621
612 def feeds
622 def feeds
613 @queries = @project.queries.find :all, :conditions => ["is_public=? or user_id=?", true, (logged_in_user ? logged_in_user.id : 0)]
623 @queries = @project.queries.find :all, :conditions => ["is_public=? or user_id=?", true, (logged_in_user ? logged_in_user.id : 0)]
614 @key = logged_in_user.get_or_create_rss_key.value if logged_in_user
624 @key = logged_in_user.get_or_create_rss_key.value if logged_in_user
615 end
625 end
616
626
617 private
627 private
618 # Find project of id params[:id]
628 # Find project of id params[:id]
619 # if not found, redirect to project list
629 # if not found, redirect to project list
620 # Used as a before_filter
630 # Used as a before_filter
621 def find_project
631 def find_project
622 @project = Project.find(params[:id])
632 @project = Project.find(params[:id])
623 @html_title = @project.name
633 @html_title = @project.name
624 rescue ActiveRecord::RecordNotFound
634 rescue ActiveRecord::RecordNotFound
625 render_404
635 render_404
626 end
636 end
627
637
628 def retrieve_selected_tracker_ids(selectable_trackers)
638 def retrieve_selected_tracker_ids(selectable_trackers)
629 if ids = params[:tracker_ids]
639 if ids = params[:tracker_ids]
630 @selected_tracker_ids = (ids.is_a? Array) ? ids.collect { |id| id.to_i.to_s } : ids.split('/').collect { |id| id.to_i.to_s }
640 @selected_tracker_ids = (ids.is_a? Array) ? ids.collect { |id| id.to_i.to_s } : ids.split('/').collect { |id| id.to_i.to_s }
631 else
641 else
632 @selected_tracker_ids = selectable_trackers.collect {|t| t.id.to_s }
642 @selected_tracker_ids = selectable_trackers.collect {|t| t.id.to_s }
633 end
643 end
634 end
644 end
635
645
636 # Retrieve query from session or build a new query
646 # Retrieve query from session or build a new query
637 def retrieve_query
647 def retrieve_query
638 if params[:query_id]
648 if params[:query_id]
639 @query = @project.queries.find(params[:query_id])
649 @query = @project.queries.find(params[:query_id])
640 @query.executed_by = logged_in_user
650 @query.executed_by = logged_in_user
641 session[:query] = @query
651 session[:query] = @query
642 else
652 else
643 if params[:set_filter] or !session[:query] or session[:query].project_id != @project.id
653 if params[:set_filter] or !session[:query] or session[:query].project_id != @project.id
644 # Give it a name, required to be valid
654 # Give it a name, required to be valid
645 @query = Query.new(:name => "_", :executed_by => logged_in_user)
655 @query = Query.new(:name => "_", :executed_by => logged_in_user)
646 @query.project = @project
656 @query.project = @project
647 if params[:fields] and params[:fields].is_a? Array
657 if params[:fields] and params[:fields].is_a? Array
648 params[:fields].each do |field|
658 params[:fields].each do |field|
649 @query.add_filter(field, params[:operators][field], params[:values][field])
659 @query.add_filter(field, params[:operators][field], params[:values][field])
650 end
660 end
651 else
661 else
652 @query.available_filters.keys.each do |field|
662 @query.available_filters.keys.each do |field|
653 @query.add_short_filter(field, params[field]) if params[field]
663 @query.add_short_filter(field, params[field]) if params[field]
654 end
664 end
655 end
665 end
656 session[:query] = @query
666 session[:query] = @query
657 else
667 else
658 @query = session[:query]
668 @query = session[:query]
659 end
669 end
660 end
670 end
661 end
671 end
662 end
672 end
@@ -1,123 +1,124
1 # redMine - project management software
1 # redMine - project management software
2 # Copyright (C) 2006 Jean-Philippe Lang
2 # Copyright (C) 2006 Jean-Philippe Lang
3 #
3 #
4 # This program is free software; you can redistribute it and/or
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
7 # of the License, or (at your option) any later version.
8 #
8 #
9 # This program is distributed in the hope that it will be useful,
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
12 # GNU General Public License for more details.
13 #
13 #
14 # You should have received a copy of the GNU General Public License
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
17
18 class Project < ActiveRecord::Base
18 class Project < ActiveRecord::Base
19 # Project statuses
19 # Project statuses
20 STATUS_ACTIVE = 1
20 STATUS_ACTIVE = 1
21 STATUS_ARCHIVED = 9
21 STATUS_ARCHIVED = 9
22
22
23 has_many :members, :dependent => :delete_all, :include => :user, :conditions => "#{User.table_name}.status=#{User::STATUS_ACTIVE}"
23 has_many :members, :dependent => :delete_all, :include => :user, :conditions => "#{User.table_name}.status=#{User::STATUS_ACTIVE}"
24 has_many :users, :through => :members
24 has_many :users, :through => :members
25 has_many :custom_values, :dependent => :delete_all, :as => :customized
25 has_many :custom_values, :dependent => :delete_all, :as => :customized
26 has_many :issues, :dependent => :destroy, :order => "#{Issue.table_name}.created_on DESC", :include => [:status, :tracker]
26 has_many :issues, :dependent => :destroy, :order => "#{Issue.table_name}.created_on DESC", :include => [:status, :tracker]
27 has_many :issue_changes, :through => :issues, :source => :journals
27 has_many :versions, :dependent => :destroy, :order => "#{Version.table_name}.effective_date DESC, #{Version.table_name}.name DESC"
28 has_many :versions, :dependent => :destroy, :order => "#{Version.table_name}.effective_date DESC, #{Version.table_name}.name DESC"
28 has_many :time_entries, :dependent => :delete_all
29 has_many :time_entries, :dependent => :delete_all
29 has_many :queries, :dependent => :delete_all
30 has_many :queries, :dependent => :delete_all
30 has_many :documents, :dependent => :destroy
31 has_many :documents, :dependent => :destroy
31 has_many :news, :dependent => :delete_all, :include => :author
32 has_many :news, :dependent => :delete_all, :include => :author
32 has_many :issue_categories, :dependent => :delete_all, :order => "#{IssueCategory.table_name}.name"
33 has_many :issue_categories, :dependent => :delete_all, :order => "#{IssueCategory.table_name}.name"
33 has_many :boards, :order => "position ASC"
34 has_many :boards, :order => "position ASC"
34 has_one :repository, :dependent => :destroy
35 has_one :repository, :dependent => :destroy
35 has_one :wiki, :dependent => :destroy
36 has_one :wiki, :dependent => :destroy
36 has_and_belongs_to_many :custom_fields, :class_name => 'IssueCustomField', :join_table => "#{table_name_prefix}custom_fields_projects#{table_name_suffix}", :association_foreign_key => 'custom_field_id'
37 has_and_belongs_to_many :custom_fields, :class_name => 'IssueCustomField', :join_table => "#{table_name_prefix}custom_fields_projects#{table_name_suffix}", :association_foreign_key => 'custom_field_id'
37 acts_as_tree :order => "name", :counter_cache => true
38 acts_as_tree :order => "name", :counter_cache => true
38
39
39 attr_protected :status
40 attr_protected :status
40
41
41 validates_presence_of :name, :description, :identifier
42 validates_presence_of :name, :description, :identifier
42 validates_uniqueness_of :name, :identifier
43 validates_uniqueness_of :name, :identifier
43 validates_associated :custom_values, :on => :update
44 validates_associated :custom_values, :on => :update
44 validates_associated :repository, :wiki
45 validates_associated :repository, :wiki
45 validates_length_of :name, :maximum => 30
46 validates_length_of :name, :maximum => 30
46 validates_format_of :name, :with => /^[\w\s\'\-]*$/i
47 validates_format_of :name, :with => /^[\w\s\'\-]*$/i
47 validates_length_of :description, :maximum => 255
48 validates_length_of :description, :maximum => 255
48 validates_length_of :identifier, :in => 3..12
49 validates_length_of :identifier, :in => 3..12
49 validates_format_of :identifier, :with => /^[a-z0-9\-]*$/
50 validates_format_of :identifier, :with => /^[a-z0-9\-]*$/
50
51
51 def identifier=(identifier)
52 def identifier=(identifier)
52 super unless identifier_frozen?
53 super unless identifier_frozen?
53 end
54 end
54
55
55 def identifier_frozen?
56 def identifier_frozen?
56 errors[:identifier].nil? && !(new_record? || identifier.blank?)
57 errors[:identifier].nil? && !(new_record? || identifier.blank?)
57 end
58 end
58
59
59 def issues_with_subprojects(include_subprojects=false)
60 def issues_with_subprojects(include_subprojects=false)
60 conditions = nil
61 conditions = nil
61 if include_subprojects && !active_children.empty?
62 if include_subprojects && !active_children.empty?
62 ids = [id] + active_children.collect {|c| c.id}
63 ids = [id] + active_children.collect {|c| c.id}
63 conditions = ["#{Issue.table_name}.project_id IN (#{ids.join(',')})"]
64 conditions = ["#{Issue.table_name}.project_id IN (#{ids.join(',')})"]
64 end
65 end
65 conditions ||= ["#{Issue.table_name}.project_id = ?", id]
66 conditions ||= ["#{Issue.table_name}.project_id = ?", id]
66 Issue.with_scope :find => { :conditions => conditions } do
67 Issue.with_scope :find => { :conditions => conditions } do
67 yield
68 yield
68 end
69 end
69 end
70 end
70
71
71 # returns latest created projects
72 # returns latest created projects
72 # non public projects will be returned only if user is a member of those
73 # non public projects will be returned only if user is a member of those
73 def self.latest(user=nil, count=5)
74 def self.latest(user=nil, count=5)
74 find(:all, :limit => count, :conditions => visible_by(user), :order => "created_on DESC")
75 find(:all, :limit => count, :conditions => visible_by(user), :order => "created_on DESC")
75 end
76 end
76
77
77 def self.visible_by(user=nil)
78 def self.visible_by(user=nil)
78 if user && user.admin?
79 if user && user.admin?
79 return ["#{Project.table_name}.status=#{Project::STATUS_ACTIVE}"]
80 return ["#{Project.table_name}.status=#{Project::STATUS_ACTIVE}"]
80 elsif user && user.memberships.any?
81 elsif user && user.memberships.any?
81 return ["#{Project.table_name}.status=#{Project::STATUS_ACTIVE} AND (#{Project.table_name}.is_public = ? or #{Project.table_name}.id IN (#{user.memberships.collect{|m| m.project_id}.join(',')}))", true]
82 return ["#{Project.table_name}.status=#{Project::STATUS_ACTIVE} AND (#{Project.table_name}.is_public = ? or #{Project.table_name}.id IN (#{user.memberships.collect{|m| m.project_id}.join(',')}))", true]
82 else
83 else
83 return ["#{Project.table_name}.status=#{Project::STATUS_ACTIVE} AND #{Project.table_name}.is_public = ?", true]
84 return ["#{Project.table_name}.status=#{Project::STATUS_ACTIVE} AND #{Project.table_name}.is_public = ?", true]
84 end
85 end
85 end
86 end
86
87
87 def active?
88 def active?
88 self.status == STATUS_ACTIVE
89 self.status == STATUS_ACTIVE
89 end
90 end
90
91
91 def archive
92 def archive
92 # Archive subprojects if any
93 # Archive subprojects if any
93 children.each do |subproject|
94 children.each do |subproject|
94 subproject.archive
95 subproject.archive
95 end
96 end
96 update_attribute :status, STATUS_ARCHIVED
97 update_attribute :status, STATUS_ARCHIVED
97 end
98 end
98
99
99 def unarchive
100 def unarchive
100 return false if parent && !parent.active?
101 return false if parent && !parent.active?
101 update_attribute :status, STATUS_ACTIVE
102 update_attribute :status, STATUS_ACTIVE
102 end
103 end
103
104
104 def active_children
105 def active_children
105 children.select {|child| child.active?}
106 children.select {|child| child.active?}
106 end
107 end
107
108
108 # Returns an array of all custom fields enabled for project issues
109 # Returns an array of all custom fields enabled for project issues
109 # (explictly associated custom fields and custom fields enabled for all projects)
110 # (explictly associated custom fields and custom fields enabled for all projects)
110 def custom_fields_for_issues(tracker)
111 def custom_fields_for_issues(tracker)
111 all_custom_fields.select {|c| tracker.custom_fields.include? c }
112 all_custom_fields.select {|c| tracker.custom_fields.include? c }
112 end
113 end
113
114
114 def all_custom_fields
115 def all_custom_fields
115 @all_custom_fields ||= (IssueCustomField.for_all + custom_fields).uniq
116 @all_custom_fields ||= (IssueCustomField.for_all + custom_fields).uniq
116 end
117 end
117
118
118 protected
119 protected
119 def validate
120 def validate
120 errors.add(parent_id, " must be a root project") if parent and parent.parent
121 errors.add(parent_id, " must be a root project") if parent and parent.parent
121 errors.add_to_base("A project with subprojects can't be a subproject") if parent and children.size > 0
122 errors.add_to_base("A project with subprojects can't be a subproject") if parent and children.size > 0
122 end
123 end
123 end
124 end
@@ -1,68 +1,71
1 <h2><%=l(:label_activity)%>: <%= "#{month_name(@month).downcase} #{@year}" %></h2>
1 <h2><%=l(:label_activity)%>: <%= "#{month_name(@month).downcase} #{@year}" %></h2>
2
2
3 <div>
3 <div>
4 <div class="rightbox">
4 <div class="rightbox">
5 <% form_tag do %>
5 <% form_tag do %>
6 <p><%= select_month(@month, :prefix => "month", :discard_type => true) %>
6 <p><%= select_month(@month, :prefix => "month", :discard_type => true) %>
7 <%= select_year(@year, :prefix => "year", :discard_type => true) %></p>
7 <%= select_year(@year, :prefix => "year", :discard_type => true) %></p>
8 <p>
8 <p>
9 <%= check_box_tag 'show_issues', 1, @show_issues %><%= hidden_field_tag 'show_issues', 0, :id => nil %> <%=l(:label_issue_plural)%><br />
9 <%= check_box_tag 'show_issues', 1, @show_issues %><%= hidden_field_tag 'show_issues', 0, :id => nil %> <%=l(:label_issue_plural)%><br />
10 <% if @project.repository %><%= check_box_tag 'show_changesets', 1, @show_changesets %><%= hidden_field_tag 'show_changesets', 0, :id => nil %> <%=l(:label_revision_plural)%><br /><% end %>
10 <% if @project.repository %><%= check_box_tag 'show_changesets', 1, @show_changesets %><%= hidden_field_tag 'show_changesets', 0, :id => nil %> <%=l(:label_revision_plural)%><br /><% end %>
11 <%= check_box_tag 'show_news', 1, @show_news %><%= hidden_field_tag 'show_news', 0, :id => nil %> <%=l(:label_news_plural)%><br />
11 <%= check_box_tag 'show_news', 1, @show_news %><%= hidden_field_tag 'show_news', 0, :id => nil %> <%=l(:label_news_plural)%><br />
12 <%= check_box_tag 'show_files', 1, @show_files %><%= hidden_field_tag 'show_files', 0, :id => nil %> <%=l(:label_attachment_plural)%><br />
12 <%= check_box_tag 'show_files', 1, @show_files %><%= hidden_field_tag 'show_files', 0, :id => nil %> <%=l(:label_attachment_plural)%><br />
13 <%= check_box_tag 'show_documents', 1, @show_documents %><%= hidden_field_tag 'show_documents', 0, :id => nil %> <%=l(:label_document_plural)%><br />
13 <%= check_box_tag 'show_documents', 1, @show_documents %><%= hidden_field_tag 'show_documents', 0, :id => nil %> <%=l(:label_document_plural)%><br />
14 <% if @project.wiki %><%= check_box_tag 'show_wiki_edits', 1, @show_wiki_edits %><%= hidden_field_tag 'show_wiki_edits', 0, :id => nil %> <%=l(:label_wiki_edit_plural)%><% end %>
14 <% if @project.wiki %><%= check_box_tag 'show_wiki_edits', 1, @show_wiki_edits %><%= hidden_field_tag 'show_wiki_edits', 0, :id => nil %> <%=l(:label_wiki_edit_plural)%><% end %>
15 </p>
15 </p>
16 <p class="textcenter"><%= submit_tag l(:button_apply), :class => 'button-small' %></p>
16 <p class="textcenter"><%= submit_tag l(:button_apply), :class => 'button-small' %></p>
17 <% end %>
17 <% end %>
18 </div>
18 </div>
19
19
20 <% @events_by_day.keys.sort {|x,y| y <=> x }.each do |day| %>
20 <% @events_by_day.keys.sort {|x,y| y <=> x }.each do |day| %>
21 <h3><%= day_name(day.cwday) %> <%= day.day %></h3>
21 <h3><%= day_name(day.cwday) %> <%= day.day %></h3>
22 <ul>
22 <ul>
23 <% @events_by_day[day].sort {|x,y| y.created_on <=> x.created_on }.each do |e| %>
23 <% @events_by_day[day].sort {|x,y| y.created_on <=> x.created_on }.each do |e| %>
24 <li><p>
24 <li><p>
25 <% if e.is_a? Issue %>
25 <% if e.is_a? Issue %>
26 <%= e.created_on.strftime("%H:%M") %> <%= link_to_issue e %>: <%=h e.subject %><br />
26 <%= e.created_on.strftime("%H:%M") %> <%= link_to_issue e %>: <%=h e.subject %><br />
27 <i><%= e.author.name %></i>
27 <i><%= e.author.name %></i>
28 <% elsif e.is_a? Journal %>
29 <%= e.created_on.strftime("%H:%M") %> <%= link_to_issue e.journalized %>
30 (<%=h (status = IssueStatus.find_by_id(e.details.first.value)) ? status.name : '?' %>): <%=h e.journalized.subject %><br />
31 <em><%=h e.user.name %><%=h ": #{truncate(e.notes, 500)}" unless e.notes.blank? %></em>
28 <% elsif e.is_a? News %>
32 <% elsif e.is_a? News %>
29 <%= e.created_on.strftime("%H:%M") %> <%=l(:label_news)%>: <%= link_to h(e.title), :controller => 'news', :action => 'show', :id => e %><br />
33 <%= e.created_on.strftime("%H:%M") %> <%=l(:label_news)%>: <%= link_to h(e.title), :controller => 'news', :action => 'show', :id => e %><br />
30 <% unless e.summary.empty? %><%=h e.summary %><br /><% end %>
34 <% unless e.summary.empty? %><%=h e.summary %><br /><% end %>
31 <i><%= e.author.name %></i>
35 <i><%= e.author.name %></i>
32 <% elsif (e.is_a? Attachment) and (e.container.is_a? Version) %>
36 <% elsif (e.is_a? Attachment) and (e.container.is_a? Version) %>
33 <%= e.created_on.strftime("%H:%M") %> <%=l(:label_attachment)%> (<%=h e.container.name %>): <%= link_to e.filename, :controller => 'projects', :action => 'list_files', :id => @project %><br />
37 <%= e.created_on.strftime("%H:%M") %> <%=l(:label_attachment)%> (<%=h e.container.name %>): <%= link_to e.filename, :controller => 'projects', :action => 'list_files', :id => @project %><br />
34 <i><%= e.author.name %></i>
38 <i><%= e.author.name %></i>
35 <% elsif (e.is_a? Attachment) and (e.container.is_a? Document) %>
39 <% elsif (e.is_a? Attachment) and (e.container.is_a? Document) %>
36 <%= e.created_on.strftime("%H:%M") %> <%=l(:label_attachment)%>: <%= e.filename %> (<%= link_to h(e.container.title), :controller => 'documents', :action => 'show', :id => e.container %>)<br />
40 <%= e.created_on.strftime("%H:%M") %> <%=l(:label_attachment)%>: <%= e.filename %> (<%= link_to h(e.container.title), :controller => 'documents', :action => 'show', :id => e.container %>)<br />
37 <i><%= e.author.name %></i>
41 <i><%= e.author.name %></i>
38 <% elsif e.is_a? Document %>
42 <% elsif e.is_a? Document %>
39 <%= e.created_on.strftime("%H:%M") %> <%=l(:label_document)%>: <%= link_to h(e.title), :controller => 'documents', :action => 'show', :id => e %><br />
43 <%= e.created_on.strftime("%H:%M") %> <%=l(:label_document)%>: <%= link_to h(e.title), :controller => 'documents', :action => 'show', :id => e %><br />
40 <% elsif e.is_a? WikiContent.versioned_class %>
44 <% elsif e.is_a? WikiContent.versioned_class %>
41 <%= e.created_on.strftime("%H:%M") %> <%=l(:label_wiki_edit)%>: <%= link_to h(WikiPage.pretty_title(e.title)), :controller => 'wiki', :page => e.title %>
45 <%= e.created_on.strftime("%H:%M") %> <%=l(:label_wiki_edit)%>: <%= link_to h(WikiPage.pretty_title(e.title)), :controller => 'wiki', :page => e.title %>
42 (<%= link_to '#' + e.version.to_s, :controller => 'wiki', :page => e.title, :version => e.version %><%= ', ' + link_to('diff', :controller => 'wiki', :action => 'diff', :page => e.title, :version => e.version) if e.version > 1 %>)<br />
46 (<%= link_to '#' + e.version.to_s, :controller => 'wiki', :page => e.title, :version => e.version %><%= ', ' + link_to('diff', :controller => 'wiki', :action => 'diff', :page => e.title, :version => e.version) if e.version > 1 %>)<br />
43 <% unless e.comments.blank? %><em><%=h e.comments %></em><% end %>
47 <% unless e.comments.blank? %><em><%=h e.comments %></em><% end %>
44 <% elsif e.is_a? Changeset %>
48 <% elsif e.is_a? Changeset %>
45 <%= e.created_on.strftime("%H:%M") %> <%=l(:label_revision)%> <%= link_to h(e.revision), :controller => 'repositories', :action => 'revision', :id => @project, :rev => e.revision %><br />
49 <%= e.created_on.strftime("%H:%M") %> <%=l(:label_revision)%> <%= link_to h(e.revision), :controller => 'repositories', :action => 'revision', :id => @project, :rev => e.revision %><br />
46 <em><%=h e.committer.blank? ? "anonymous" : e.committer %><%= h(": #{truncate(e.comments, 500)}") unless e.comments.blank? %></em>
50 <em><%=h e.committer.blank? ? "anonymous" : e.committer %><%= h(": #{truncate(e.comments, 500)}") unless e.comments.blank? %></em>
47 <% end %>
51 <% end %>
48 </p></li>
52 </p></li>
49
53
50 <% end %>
54 <% end %>
51 </ul>
55 </ul>
52 <% end %>
56 <% end %>
53 <% if @events_by_day.empty? %><p><i><%= l(:label_no_data) %></i></p><% end %>
57 <% if @events_by_day.empty? %><p><i><%= l(:label_no_data) %></i></p><% end %>
54
58
55 <div style="float:left;">
59 <div style="float:left;">
60 <% prev_params = params.clone.update :year => (@month==1 ? @year-1 : @year), :month =>(@month==1 ? 12 : @month-1) %>
56 <%= link_to_remote ('&#171; ' + (@month==1 ? "#{month_name(12)} #{@year-1}" : "#{month_name(@month-1)}")),
61 <%= link_to_remote ('&#171; ' + (@month==1 ? "#{month_name(12)} #{@year-1}" : "#{month_name(@month-1)}")),
57 {:update => "content", :url => { :year => (@month==1 ? @year-1 : @year), :month =>(@month==1 ? 12 : @month-1) }},
62 {:update => "content", :url => prev_params}, {:href => url_for(prev_params)} %>
58 {:href => url_for(:action => 'activity', :year => (@month==1 ? @year-1 : @year), :month =>(@month==1 ? 12 : @month-1))}
59 %>
60 </div>
63 </div>
61 <div style="float:right;">
64 <div style="float:right;">
65 <% next_params = params.clone.update :year => (@month==12 ? @year+1 : @year), :month =>(@month==12 ? 1 : @month+1) %>
62 <%= link_to_remote ((@month==12 ? "#{month_name(1)} #{@year+1}" : "#{month_name(@month+1)}") + ' &#187;'),
66 <%= link_to_remote ((@month==12 ? "#{month_name(1)} #{@year+1}" : "#{month_name(@month+1)}") + ' &#187;'),
63 {:update => "content", :url => { :year => (@month==12 ? @year+1 : @year), :month =>(@month==12 ? 1 : @month+1) }},
67 {:update => "content", :url => next_params}, {:href => url_for(next_params)} %>
64 {:href => url_for(:action => 'activity', :year => (@month==12 ? @year+1 : @year), :month =>(@month==12 ? 1 : @month+1))}
68 &nbsp;
65 %>&nbsp;
66 </div>
69 </div>
67 <br />
70 <br />
68 </div>
71 </div>
General Comments 0
You need to be logged in to leave comments. Login now