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