comparison app/controllers/activities_controller.rb @ 511:107d36338b70 live

Merge from branch "cannam"
author Chris Cannam
date Thu, 14 Jul 2011 10:43:07 +0100
parents 0c939c159af4
children 066b55d7c053 433d4f72a19b
comparison
equal deleted inserted replaced
451:a9f6345cb43d 511:107d36338b70
1 # Redmine - project management software
2 # Copyright (C) 2006-2011 Jean-Philippe Lang
3 #
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
13 #
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
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
1 class ActivitiesController < ApplicationController 18 class ActivitiesController < ApplicationController
2 menu_item :activity 19 menu_item :activity
3 before_filter :find_optional_project 20 before_filter :find_optional_project
4 accept_key_auth :index 21 accept_rss_auth :index
5 22
6 def index 23 def index
7 @days = Setting.activity_days_default.to_i 24 @days = Setting.activity_days_default.to_i
8 25
9 if params[:from] 26 if params[:from]
10 begin; @date_to = params[:from].to_date + 1; rescue; end 27 begin; @date_to = params[:from].to_date + 1; rescue; end
11 end 28 end
12 29
13 @date_to ||= Date.today + 1 30 @date_to ||= Date.today + 1
14 @date_from = @date_to - @days 31 @date_from = @date_to - @days
15 @with_subprojects = params[:with_subprojects].nil? ? Setting.display_subprojects_issues? : (params[:with_subprojects] == '1') 32 @with_subprojects = params[:with_subprojects].nil? ? Setting.display_subprojects_issues? : (params[:with_subprojects] == '1')
16 @author = (params[:user_id].blank? ? nil : User.active.find(params[:user_id])) 33 @author = (params[:user_id].blank? ? nil : User.active.find(params[:user_id]))
17 34
18 @activity = Redmine::Activity::Fetcher.new(User.current, :project => @project, 35 @activity = Redmine::Activity::Fetcher.new(User.current, :project => @project,
19 :with_subprojects => @with_subprojects, 36 :with_subprojects => @with_subprojects,
20 :author => @author) 37 :author => @author)
21 @activity.scope_select {|t| !params["show_#{t}"].nil?} 38 @activity.scope_select {|t| !params["show_#{t}"].nil?}
22 @activity.scope = (@author.nil? ? :default : :all) if @activity.scope.empty? 39 @activity.scope = (@author.nil? ? :default : :all) if @activity.scope.empty?
23 40
24 events = @activity.events(@date_from, @date_to) 41 events = @activity.events(@date_from, @date_to)
25 42
26 if events.empty? || stale?(:etag => [events.first, User.current]) 43 if events.empty? || stale?(:etag => [@activity.scope, @date_to, @date_from, @with_subprojects, @author, events.first, User.current, current_language])
27 respond_to do |format| 44 respond_to do |format|
28 format.html { 45 format.html {
29 @events_by_day = events.group_by(&:event_date) 46 @events_by_day = events.group_by(&:event_date)
30 render :layout => false if request.xhr? 47 render :layout => false if request.xhr?
31 } 48 }
32 format.atom { 49 format.atom {
33 title = l(:label_activity) 50 title = l(:label_activity)
38 end 55 end
39 render_feed(events, :title => "#{@project || Setting.app_title}: #{title}") 56 render_feed(events, :title => "#{@project || Setting.app_title}: #{title}")
40 } 57 }
41 end 58 end
42 end 59 end
43 60
44 rescue ActiveRecord::RecordNotFound 61 rescue ActiveRecord::RecordNotFound
45 render_404 62 render_404
46 end 63 end
47 64
48 private 65 private
53 @project = Project.find(params[:id]) 70 @project = Project.find(params[:id])
54 authorize 71 authorize
55 rescue ActiveRecord::RecordNotFound 72 rescue ActiveRecord::RecordNotFound
56 render_404 73 render_404
57 end 74 end
58
59 end 75 end