diff options
author | Eric Davis <edavis@littlestreamsoftware.com> | 2010-08-27 14:05:54 +0000 |
---|---|---|
committer | Eric Davis <edavis@littlestreamsoftware.com> | 2010-08-27 14:05:54 +0000 |
commit | b925325ddbd5fb594f20221dd724f7822ed4c3d3 (patch) | |
tree | 91e51c09bf06bbbe143ec0b530caad6bd9725448 /app/controllers/activities_controller.rb | |
parent | 5b08b2f33d4072e2a41545637ef40365c3ef7ea4 (diff) | |
download | redmine-b925325ddbd5fb594f20221dd724f7822ed4c3d3.tar.gz redmine-b925325ddbd5fb594f20221dd724f7822ed4c3d3.zip |
Refactor: extract ProjectsController#activity to a new Activities controller.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4047 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/controllers/activities_controller.rb')
-rw-r--r-- | app/controllers/activities_controller.rb | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/app/controllers/activities_controller.rb b/app/controllers/activities_controller.rb new file mode 100644 index 000000000..ae6a67369 --- /dev/null +++ b/app/controllers/activities_controller.rb @@ -0,0 +1,59 @@ +class ActivitiesController < ApplicationController + menu_item :activity + before_filter :find_optional_project + accept_key_auth :index + + def index + @days = Setting.activity_days_default.to_i + + if params[:from] + begin; @date_to = params[:from].to_date + 1; rescue; end + end + + @date_to ||= Date.today + 1 + @date_from = @date_to - @days + @with_subprojects = params[:with_subprojects].nil? ? Setting.display_subprojects_issues? : (params[:with_subprojects] == '1') + @author = (params[:user_id].blank? ? nil : User.active.find(params[:user_id])) + + @activity = Redmine::Activity::Fetcher.new(User.current, :project => @project, + :with_subprojects => @with_subprojects, + :author => @author) + @activity.scope_select {|t| !params["show_#{t}"].nil?} + @activity.scope = (@author.nil? ? :default : :all) if @activity.scope.empty? + + events = @activity.events(@date_from, @date_to) + + if events.empty? || stale?(:etag => [events.first, User.current]) + respond_to do |format| + format.html { + @events_by_day = events.group_by(&:event_date) + render :layout => false if request.xhr? + } + format.atom { + title = l(:label_activity) + if @author + title = @author.name + elsif @activity.scope.size == 1 + title = l("label_#{@activity.scope.first.singularize}_plural") + end + render_feed(events, :title => "#{@project || Setting.app_title}: #{title}") + } + end + end + + rescue ActiveRecord::RecordNotFound + render_404 + end + + private + + # TODO: refactor, duplicated in projects_controller + def find_optional_project + return true unless params[:id] + @project = Project.find(params[:id]) + authorize + rescue ActiveRecord::RecordNotFound + render_404 + end + +end |