@@ -1,75 +1,75 | |||||
1 | # Redmine - project management software |
|
1 | # Redmine - project management software | |
2 | # Copyright (C) 2006-2012 Jean-Philippe Lang |
|
2 | # Copyright (C) 2006-2012 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 ActivitiesController < ApplicationController |
|
18 | class ActivitiesController < ApplicationController | |
19 | menu_item :activity |
|
19 | menu_item :activity | |
20 | before_filter :find_optional_project |
|
20 | before_filter :find_optional_project | |
21 | accept_rss_auth :index |
|
21 | accept_rss_auth :index | |
22 |
|
22 | |||
23 | def index |
|
23 | def index | |
24 | @days = Setting.activity_days_default.to_i |
|
24 | @days = Setting.activity_days_default.to_i | |
25 |
|
25 | |||
26 | if params[:from] |
|
26 | if params[:from] | |
27 | begin; @date_to = params[:from].to_date + 1; rescue; end |
|
27 | begin; @date_to = params[:from].to_date + 1; rescue; end | |
28 | end |
|
28 | end | |
29 |
|
29 | |||
30 | @date_to ||= Date.today + 1 |
|
30 | @date_to ||= Date.today + 1 | |
31 | @date_from = @date_to - @days |
|
31 | @date_from = @date_to - @days | |
32 | @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') | |
33 | @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])) | |
34 |
|
34 | |||
35 | @activity = Redmine::Activity::Fetcher.new(User.current, :project => @project, |
|
35 | @activity = Redmine::Activity::Fetcher.new(User.current, :project => @project, | |
36 | :with_subprojects => @with_subprojects, |
|
36 | :with_subprojects => @with_subprojects, | |
37 | :author => @author) |
|
37 | :author => @author) | |
38 | @activity.scope_select {|t| !params["show_#{t}"].nil?} |
|
38 | @activity.scope_select {|t| !params["show_#{t}"].nil?} | |
39 | @activity.scope = (@author.nil? ? :default : :all) if @activity.scope.empty? |
|
39 | @activity.scope = (@author.nil? ? :default : :all) if @activity.scope.empty? | |
40 |
|
40 | |||
41 | events = @activity.events(@date_from, @date_to) |
|
41 | events = @activity.events(@date_from, @date_to) | |
42 |
|
42 | |||
43 | if events.empty? || stale?(:etag => [@activity.scope, @date_to, @date_from, @with_subprojects, @author, events.first, User.current, current_language]) |
|
43 | if events.empty? || stale?(:etag => [@activity.scope, @date_to, @date_from, @with_subprojects, @author, events.first, events.size, User.current, current_language]) | |
44 | respond_to do |format| |
|
44 | respond_to do |format| | |
45 | format.html { |
|
45 | format.html { | |
46 | @events_by_day = events.group_by {|event| User.current.time_to_date(event.event_datetime)} |
|
46 | @events_by_day = events.group_by {|event| User.current.time_to_date(event.event_datetime)} | |
47 | render :layout => false if request.xhr? |
|
47 | render :layout => false if request.xhr? | |
48 | } |
|
48 | } | |
49 | format.atom { |
|
49 | format.atom { | |
50 | title = l(:label_activity) |
|
50 | title = l(:label_activity) | |
51 | if @author |
|
51 | if @author | |
52 | title = @author.name |
|
52 | title = @author.name | |
53 | elsif @activity.scope.size == 1 |
|
53 | elsif @activity.scope.size == 1 | |
54 | title = l("label_#{@activity.scope.first.singularize}_plural") |
|
54 | title = l("label_#{@activity.scope.first.singularize}_plural") | |
55 | end |
|
55 | end | |
56 | render_feed(events, :title => "#{@project || Setting.app_title}: #{title}") |
|
56 | render_feed(events, :title => "#{@project || Setting.app_title}: #{title}") | |
57 | } |
|
57 | } | |
58 | end |
|
58 | end | |
59 | end |
|
59 | end | |
60 |
|
60 | |||
61 | rescue ActiveRecord::RecordNotFound |
|
61 | rescue ActiveRecord::RecordNotFound | |
62 | render_404 |
|
62 | render_404 | |
63 | end |
|
63 | end | |
64 |
|
64 | |||
65 | private |
|
65 | private | |
66 |
|
66 | |||
67 | # TODO: refactor, duplicated in projects_controller |
|
67 | # TODO: refactor, duplicated in projects_controller | |
68 | def find_optional_project |
|
68 | def find_optional_project | |
69 | return true unless params[:id] |
|
69 | return true unless params[:id] | |
70 | @project = Project.find(params[:id]) |
|
70 | @project = Project.find(params[:id]) | |
71 | authorize |
|
71 | authorize | |
72 | rescue ActiveRecord::RecordNotFound |
|
72 | rescue ActiveRecord::RecordNotFound | |
73 | render_404 |
|
73 | render_404 | |
74 | end |
|
74 | end | |
75 | end |
|
75 | end |
General Comments 0
You need to be logged in to leave comments.
Login now