##// END OF EJS Templates
set default category_id instead of the object (#11665)...
set default category_id instead of the object (#11665) Rails 2.3 still has issues with synchronizing the association_id and association attributes of an object. That means, if you set the association with an object first and then just set the id afterwards, the object wins and the setting of the id gets lost. This is not an issue in Rails >= 3.1 anymore. Contributed by Holger Just. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@10226 e93f8b46-1217-0410-a6f0-8f06a7374b81

File last commit:

r6077:93c2b92a4b5b
r10043:14dcefaa97f9
Show More
activities_controller.rb
75 lines | 2.7 KiB | text/x-ruby | RubyLexer
/ app / controllers / activities_controller.rb
Jean-Philippe Lang
Separation of RSS/API auth actions....
r6077 # Redmine - project management software
# Copyright (C) 2006-2011 Jean-Philippe Lang
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Eric Davis
Refactor: extract ProjectsController#activity to a new Activities controller....
r3933 class ActivitiesController < ApplicationController
menu_item :activity
before_filter :find_optional_project
Jean-Philippe Lang
Separation of RSS/API auth actions....
r6077 accept_rss_auth :index
Eric Davis
Refactor: extract ProjectsController#activity to a new Activities controller....
r3933
def index
@days = Setting.activity_days_default.to_i
Toshi MARUYAMA
remove trailing white-spaces and an empty line from activities controller source....
r5715
Eric Davis
Refactor: extract ProjectsController#activity to a new Activities controller....
r3933 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]))
Toshi MARUYAMA
remove trailing white-spaces and an empty line from activities controller source....
r5715
@activity = Redmine::Activity::Fetcher.new(User.current, :project => @project,
Eric Davis
Refactor: extract ProjectsController#activity to a new Activities controller....
r3933 :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)
Toshi MARUYAMA
remove trailing white-spaces and an empty line from activities controller source....
r5715
Jean-Philippe Lang
Takes more parameters into account to determine activity freshness (#7188)....
r4465 if events.empty? || stale?(:etag => [@activity.scope, @date_to, @date_from, @with_subprojects, @author, events.first, User.current, current_language])
Eric Davis
Refactor: extract ProjectsController#activity to a new Activities controller....
r3933 respond_to do |format|
Toshi MARUYAMA
remove trailing white-spaces and an empty line from activities controller source....
r5715 format.html {
Eric Davis
Refactor: extract ProjectsController#activity to a new Activities controller....
r3933 @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
Toshi MARUYAMA
remove trailing white-spaces and an empty line from activities controller source....
r5715
Eric Davis
Refactor: extract ProjectsController#activity to a new Activities controller....
r3933 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